runtime: speed up growslice by avoiding divisions
Only compute the number of maximum allowed elements per slice once. Special case newcap computation for slices with byte sized elements. name old time/op new time/op delta GrowSliceBytes-2 61.1ns ± 1% 43.4ns ± 1% -29.00% (p=0.000 n=20+20) GrowSliceInts-2 85.9ns ± 1% 75.7ns ± 1% -11.80% (p=0.000 n=20+20) Change-Id: I5d9c0d5987cdd108ac29dc32e31912dcefa2324d Reviewed-on: https://go-review.googlesource.com/20653Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
Please register or sign in to comment