]> Cypherpunks repositories - gostls13.git/commit
strconv: use bounded bits.TrailingZeros instead of shifts table
authorMartin Möhrmann <moehrmann@google.com>
Tue, 1 May 2018 09:39:17 +0000 (11:39 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 1 May 2018 15:48:15 +0000 (15:48 +0000)
commitd29ec40e19fa0548292bb0bf2a4fb88920838877
treedb7d057db12d558982bada34e28c15cb55946a6c
parentf8ef6ed24a65ef50cb81510a5720abf406c90642
strconv: use bounded bits.TrailingZeros instead of shifts table

The strconv shifts table is 320 bytes (amd64) and is present in
many binaries since integer formatting is very common.

Instead of using a precalculated table with shift amounts
use a bounded bits.TrailingZeros to determine the shift amount
to format numbers in a base that is a power of 2.

amd64:
name        old time/op  new time/op  delta
AppendUint   379ns ± 1%   286ns ± 2%  -24.62%  (p=0.000 n=20+19)

Change-Id: Ib94d9b033321b41e975868943c7fcd9428c5111e
Reviewed-on: https://go-review.googlesource.com/110478
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/build/deps_test.go
src/strconv/itoa.go