3 ms·
go1.15 re-added small integer packing into interfaces: https://go.dev/doc/go1.15#runtime https://go.dev/doc/go1.15#runtime
by ominous_prime 2y ago
go1.15 re-added small integer packing into interfaces: https://go.dev/doc/go1.15#runtime https://go.dev/doc/go1.15#runtime
- masklinn 2y agoIt didn't, actually. Instead go 1.15 has a static array of the first 256 positive integers, and when it needs to box one for an interface it gets a pointer into that array instead: https://go-review.googlesource.com/c/go/+/216401/4/src/runtime/iface.go https://go-review.googlesource.com/c/go/+/216401/4/src/runti... This array is also used for single-byte strings (which previously had its own array): https://go-review.googlesource.com/c/go/+/221979/3/src/runtime/string.go https://go-review.googlesource.com/c/go/+/221979/3/src/runti...
- ominous_prime 2y agoIt didn't, do what? I would consider the first 256 integers to be "small integers" ;) > Converting a small integer value into an interface value no longer causes allocation I forgot that it can also be used for single byte strings, That's not an optimization I ever encountered being useful, but it's there!
- masklinn 2y ago> It didn't, do what? Reintroduce “packing into interfaces”. It did a completely different thing. Small integers remain not inlined.