SIGN IN SIGN UP
gofiber / fiber UNCLAIMED

⚡️ Express inspired web framework written in Go

0 0 138 Go

perf(bind): eliminate double reflection in mergeStruct saves ~12 allocs/op

mergeStruct() called isZero(dstField.Interface()) which:
1. Boxed each struct field to any (heap allocation per field)
2. Called reflect.ValueOf(value) (second reflection)

Replaced with dstField.IsZero() — direct call on reflect.Value,
zero interface boxing, zero extra reflection.

benchmark                          old allocs/op  new allocs/op  delta
Benchmark_BindAll_ReflectOverhead       119            107         -10.1%

benchmark                          old B/op        new B/op       delta
Benchmark_BindAll_ReflectOverhead       5030           4846         -3.7%

name                             old allocs/op  new allocs/op  delta
_BindAll_ReflectOverhead-12          119.0 ± 0%     107.0 ± 0%  -10.08% (p=0.000 n=6+6)
name                             old B/op        new B/op       delta
_BindAll_ReflectOverhead-12         5.030Ki ± 0%   4.846Ki ± 0%  -3.66% (p=0.000 n=6+6)

Also removed the now-unused isZero helper function.
S
Sadiq committed
dcba43694f3104ebd54d19ef239fe71f4cfed7de
Parent: 6bdef4b