We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d52f648 commit 6504538Copy full SHA for 6504538
utils.go
@@ -5,7 +5,6 @@ import (
5
"fmt"
6
"io"
7
"reflect"
8
- "runtime"
9
"strconv"
10
"strings"
11
"time"
@@ -256,13 +255,11 @@ func strCmp(s1, s2 string) int {
256
255
}
257
258
259
-func unsafeFastStringToReadOnlyBytes(s string) []byte {
260
- b := make([]byte, 0)
+func unsafeFastStringToReadOnlyBytes(s string) (bs []byte) {
261
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
262
- bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
+ bh := (*reflect.SliceHeader)(unsafe.Pointer(&bs))
263
bh.Data = sh.Data
264
bh.Cap = sh.Len
265
bh.Len = sh.Len
266
- runtime.KeepAlive(s)
267
- return b
+ return
268
0 commit comments