• Martin Möhrmann's avatar
    strconv: speed up atoi for common cases · 06ed8f0d
    Martin Möhrmann authored
    Add compile time constants for bases 10 and 16 instead of computing the cutoff
    value on every invocation of ParseUint by a division.
    
    Reduce usage of slice operations.
    
    amd64:
    benchmark              old ns/op     new ns/op     delta
    BenchmarkAtoi          44.6          36.0          -19.28%
    BenchmarkAtoiNeg       44.2          38.9          -11.99%
    BenchmarkAtoi64        72.5          56.7          -21.79%
    BenchmarkAtoi64Neg     66.1          58.6          -11.35%
    
    386:
    benchmark              old ns/op     new ns/op     delta
    BenchmarkAtoi          86.6          73.0          -15.70%
    BenchmarkAtoiNeg       86.6          72.3          -16.51%
    BenchmarkAtoi64        126           108           -14.29%
    BenchmarkAtoi64Neg     126           108           -14.29%
    
    Change-Id: I0a271132120d776c97bb4ed1099793c73e159893
    Reviewed-on: https://go-review.googlesource.com/2460Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    06ed8f0d
Name
Last commit
Last update
..
testdata Loading commit data...
atob.go Loading commit data...
atob_test.go Loading commit data...
atof.go Loading commit data...
atof_test.go Loading commit data...
atoi.go Loading commit data...
atoi_test.go Loading commit data...
decimal.go Loading commit data...
decimal_test.go Loading commit data...
extfloat.go Loading commit data...
fp_test.go Loading commit data...
ftoa.go Loading commit data...
ftoa_test.go Loading commit data...
internal_test.go Loading commit data...
isprint.go Loading commit data...
itoa.go Loading commit data...
itoa_test.go Loading commit data...
makeisprint.go Loading commit data...
quote.go Loading commit data...
quote_example_test.go Loading commit data...
quote_test.go Loading commit data...
strconv_test.go Loading commit data...