json-iterator/go

Proposal: grow buffers more efficiently

bboreham opened this issue · 0 comments

json-iterator is using append in many places to grow a buffer, e.g.:

go/stream.go

Line 68 in 71ac162

stream.buf = append(stream.buf, p...)

return append(buf, byte(v>>16), byte(v>>8), byte(v))

As noted at golang/go#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.