some more uses:
string([]byte):
// Some internal compiler optimizations use this function.
// - Used for m[string(k)] lookup where m is a string-keyed map and k is a
[]byte.
// - Used for "<"+string(b)+">" concatenation where b is []byte.
// - Used for string(b)=="foo" comparison where b is [
On Mon, Feb 13, 2017 at 12:31 PM, Alex Flint wrote:
>
> As of go1.8, do conversions between strings and byte slices always generate
> a copy?
Usually but not absolutely always.
The gc compiler has an optimization for map lookups. For a
map[string]T, when s is a []byte, m[string(s)] will not mak
As of go1.8, do conversions between strings and byte slices always generate
a copy?
I understand the immutability guarantees in the language spec, but I'm
interested in this from an efficiency standpoint. I can imagine a compiler
that analyzes whether a byte slice created from such a conversion