MCPcopy Index your code
hub / github.com/dropbox/godropbox / ShallowString

Function ShallowString

strings/intern.go:13–19  ·  view source on GitHub ↗

ShallowString force casts a []byte to a string. USE AT YOUR OWN RISK

(b []byte)

Source from the content-addressed store, hash-verified

11// ShallowString force casts a []byte to a string.
12// USE AT YOUR OWN RISK
13func ShallowString(b []byte) (s string) {
14 pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b))
15 pstring := (*reflect.StringHeader)(unsafe.Pointer(&s))
16 pstring.Data = pbytes.Data
17 pstring.Len = pbytes.Len
18 return
19}
20
21// InternStringPool is a simple thread-safe intern string pool.
22type InternStringPool struct {

Callers 1

InternBytesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected