$ the-wire · showcase
encoding/json/v2 trims redundant buffer stores
By RepoJournal · Filed · About Go · Composed from the cited sources · methodology
A single commit in golang/go introduces a CommitBuffer helper that removes redundant pointer stores and their associated write barriers from the jsontext and encoding/json/v2 encoders, a micro-optimization with no API change for callers.
encoding/json/jsontext, encoding/json/v2: avoid redundant buffer stores golang/go
Jake Bailey's change adds CommitBuffer, which publishes an appended slice by reslicing the encoder buffer when it retains the backing array and storing the returned slice otherwise. Applied at the existing post-append buffer updates in jsontext and the default marshalers, it targets pointer stores and write barriers rather than allocation counts; the benchmark cited is a single run on linux/amd...