• Brad Fitzpatrick's avatar
    json: use strconv.Append variants to avoid allocations in encoding · 29264c6f
    Brad Fitzpatrick authored
    Before/after, best of 3:
    json.BenchmarkCodeEncoder  10  183495300 ns/op  10.58 MB/s
    ->
    json.BenchmarkCodeEncoder  10  133025100 ns/op  14.59 MB/s
    
    But don't get too excited about this.  These benchmarks, while
    stable at any point of time, fluctuate wildly with any line of
    code added or removed anywhere in the path due to stack splitting
    issues.
    
    It's currently much faster, though, and this is the API that
    doesn't allocate so should always be faster in theory.
    
    R=golang-dev, dsymonds, rsc, r, gri
    CC=golang-dev
    https://golang.org/cl/5411052
    29264c6f
encode.go 13 KB