go
go copied to clipboard
Proposal: grow buffers more efficiently
json-iterator is using append in many places to grow a buffer, e.g.:
https://github.com/json-iterator/go/blob/71ac16282d122fdd1e3a6d3e7f79b79b4cc3b50e/stream.go#L68
https://github.com/json-iterator/go/blob/71ac16282d122fdd1e3a6d3e7f79b79b4cc3b50e/stream_int.go#L29
As noted at https://github.com/golang/go/issues/50774, append is designed to minimize space wasted at the end of the buffer, whereas most people using json-iterator probably want to optimise for minimum CPU usage.
I can make a PR, but posting this as an issue first to get feedback.