MCPcopy
hub / github.com/google/gvisor / StringFromImmutableBytes

Function StringFromImmutableBytes

pkg/gohacks/string_go120_unsafe.go:34–39  ·  view source on GitHub ↗

StringFromImmutableBytes is equivalent to string(bs), except that it uses the same memory backing bs instead of making a heap-allocated copy. This is only valid if bs is never mutated after StringFromImmutableBytes returns.

(bs []byte)

Source from the content-addressed store, hash-verified

32// the same memory backing bs instead of making a heap-allocated copy. This is
33// only valid if bs is never mutated after StringFromImmutableBytes returns.
34func StringFromImmutableBytes(bs []byte) string {
35 if len(bs) == 0 {
36 return ""
37 }
38 return unsafe.String(&bs[0], len(bs))
39}

Callers 6

copyInXattrValueFunction · 0.92
loadStringFunction · 0.92
loadRefFunction · 0.92
StringMethod · 0.92
CopyStringInFunction · 0.92

Calls 1

StringMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…