Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ func BytesToStringWithNoCopy(bytes []byte) string {
}

func StringToBytesWithNoCopy(s string) []byte {
x := (*[2]uintptr)(unsafe.Pointer(&s))
h := [3]uintptr{x[0], x[1], x[1]}
return *(*[]byte)(unsafe.Pointer(&h))
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{str, len(str)},
))
}

func ListToMap(list []string) map[string]struct{} {
Expand Down