• Daniel Martí's avatar
    encoding/json: avoid some more pointer receivers · 88f4bcce
    Daniel Martí authored
    A few encoder struct types, such as map and slice, only encapsulate
    other prepared encoder funcs. Using pointer receivers has no advantage,
    and makes calling these methods slightly more expensive.
    
    Not a huge performance win, but certainly an easy one. The struct types
    used in the benchmark below contain one slice field and one pointer
    field.
    
    name           old time/op    new time/op    delta
    CodeEncoder-4    5.48ms ± 0%    5.39ms ± 0%  -1.66%  (p=0.010 n=6+4)
    
    name           old speed      new speed      delta
    CodeEncoder-4   354MB/s ± 0%   360MB/s ± 0%  +1.69%  (p=0.010 n=6+4)
    
    Updates #5683.
    
    Change-Id: I9f78dbe07fcc6fbf19a6d96c22f5d6970db9eca4
    Reviewed-on: https://go-review.googlesource.com/131400
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    88f4bcce
encode.go 34.1 KB