• Daniel Martí's avatar
    encoding/json: inline fieldByIndex · 75e7e05a
    Daniel Martí authored
    This function was only used in a single place - in the field encoding
    loop within the struct encoder.
    
    Inlining the function call manually lets us get rid of the call
    overhead. But most importantly, it lets us simplify the logic afterward.
    We no longer need to use reflect.Value{} and !fv.IsValid(), as we can
    skip the field immediately.
    
    The two factors combined (mostly just the latter) give a moderate speed
    improvement to this hot loop.
    
    name           old time/op    new time/op    delta
    CodeEncoder-4    6.01ms ± 1%    5.91ms ± 1%  -1.66%  (p=0.002 n=6+6)
    
    name           old speed      new speed      delta
    CodeEncoder-4   323MB/s ± 1%   328MB/s ± 1%  +1.69%  (p=0.002 n=6+6)
    
    Updates #5683.
    
    Change-Id: I12757c325a68abb2856026cf719c122612a1f38e
    Reviewed-on: https://go-review.googlesource.com/125417
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    75e7e05a
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...