• Dave Cheney's avatar
    reflect: avoid zeroing memory that will be overwritten · adb1e67f
    Dave Cheney authored
    Avoid new'ing memory that will be overwritten by assignment.
    
    name              old time/op    new time/op    delta
    Call-4               160ns ± 4%     155ns ± 2%  -3.19%        (p=0.003 n=10+10)
    FieldByName1-4      94.5ns ± 2%    95.2ns ± 1%  +0.65%          (p=0.026 n=9+9)
    FieldByName2-4      3.09µs ± 4%    3.13µs ± 2%    ~           (p=0.165 n=10+10)
    FieldByName3-4      19.8µs ± 1%    19.9µs ± 1%    ~            (p=0.395 n=10+8)
    InterfaceBig-4      11.6ns ± 0%    11.7ns ± 0%  +0.86%          (p=0.000 n=8+9)
    InterfaceSmall-4    11.7ns ± 0%    11.7ns ± 0%    ~     (all samples are equal)
    New-4               26.6ns ± 0%    26.4ns ± 0%  -0.64%         (p=0.000 n=10+9)
    
    name              old alloc/op   new alloc/op   delta
    Call-4              0.00B ±NaN%    0.00B ±NaN%    ~     (all samples are equal)
    
    name              old allocs/op  new allocs/op  delta
    Call-4               0.00 ±NaN%     0.00 ±NaN%    ~     (all samples are equal)
    
    Change-Id: I12c85d4e65245598669dd6f66beb0744ec9b9d6d
    Reviewed-on: https://go-review.googlesource.com/28011
    Run-TryBot: Dave Cheney <dave@cheney.net>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    adb1e67f
type.go 83.7 KB