In skimming through the JSON updates in 1.2, I noticed something curious WRT buffer reuse:encode.go creates a leaky bucket pool (encodeStatePool). It's used by json.Encoder but ignored by json.Marshal. Is this intentional or an oversight?
IMHO there is little benefit in reusing encodeState{} for json.Marshal because Marshal willallocate the byte slice every time anyway, so little point in saving memory for encodeState.in other words, if you care about allocation, you should definitely use the streaming interface.
At the moment, there's no benefit to using the streaming interface
Also, future optimization could certainly reduce the memory allocated by reduced buffering exploiting
the nature of the streaming interface. The same kind of optimization couldn't apply the Marshal case.
Of course there are people interested in getting Encoder allocate less (e.g., https://codereview.appspot.com/9365044)