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)
| 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. |
| 34 | func StringFromImmutableBytes(bs []byte) string { |
| 35 | if len(bs) == 0 { |
| 36 | return "" |
| 37 | } |
| 38 | return unsafe.String(&bs[0], len(bs)) |
| 39 | } |
searching dependent graphs…