Skip to content

Commit

Permalink
msgpack: add bounds check hint to compiler to fields
Browse files Browse the repository at this point in the history
name                         old time/op    new time/op    delta
_correctFilels/Named-20        9.55µs ± 0%    9.45µs ± 1%  -1.02%  (p=0.008 n=5+5)
_correctFilels/Empty-20        9.60µs ± 0%    9.88µs ±10%    ~     (p=1.000 n=5+5)
_correctFilels/OmitEmpty-20    10.9µs ± 1%    11.2µs ± 6%    ~     (p=0.095 n=5+5)
[Geo mean]                     10.0µs         10.1µs       +1.38%

name                         old alloc/op   new alloc/op   delta
_correctFilels/Named-20        4.75kB ± 0%    4.75kB ± 0%    ~     (all equal)
_correctFilels/Empty-20        4.75kB ± 0%    4.75kB ± 0%    ~     (p=0.333 n=5+4)
_correctFilels/OmitEmpty-20    5.10kB ± 0%    5.10kB ± 0%    ~     (all equal)
[Geo mean]                     4.86kB         4.86kB       -0.00%

name                         old allocs/op  new allocs/op  delta
_correctFilels/Named-20          96.0 ± 0%      96.0 ± 0%    ~     (all equal)
_correctFilels/Empty-20          96.0 ± 0%      96.0 ± 0%    ~     (all equal)
_correctFilels/OmitEmpty-20      96.0 ± 0%      96.0 ± 0%    ~     (all equal)
[Geo mean]                       96.0           96.0       +0.00%

Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Feb 24, 2022
1 parent 7e7bcb6 commit 2732b5d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions msgpack/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func collectFields(fields []*field, t reflect.Type, visited map[reflect.Type]boo
}

if len(index) == d {
_ = fields[len(fields)-1] // bounds check hint to compiler

// There is another field with same name and same depth
// Remove that field and skip this field
j := 0
Expand Down

0 comments on commit 2732b5d

Please sign in to comment.