ShallowString force casts a []byte to a string. USE AT YOUR OWN RISK
(b []byte)
| 11 | // ShallowString force casts a []byte to a string. |
| 12 | // USE AT YOUR OWN RISK |
| 13 | func 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. |
| 22 | type InternStringPool struct { |