diff options
| author | Robert Griesemer <gri@golang.org> | 2017-02-28 11:52:43 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-02-28 20:55:13 +0000 |
| commit | 83bc4a2feed1c7dc37026278364772483fe73618 (patch) | |
| tree | 102ab5f8458a3e21bca97b4d3986a7cd2ca44e6b /src/math/bits/bits_impl.go | |
| parent | 9515cb511a1210e013c26354ea09e786acd61365 (diff) | |
| download | go-83bc4a2feed1c7dc37026278364772483fe73618.tar.xz | |
math/bits: faster LeadingZeros and Len functions
benchmark old ns/op new ns/op delta
BenchmarkLeadingZeros-8 8.43 3.10 -63.23%
BenchmarkLeadingZeros8-8 8.13 1.33 -83.64%
BenchmarkLeadingZeros16-8 7.34 2.07 -71.80%
BenchmarkLeadingZeros32-8 7.99 2.87 -64.08%
BenchmarkLeadingZeros64-8 8.13 2.96 -63.59%
Measured on 2.3 GHz Intel Core i7 running macOS 10.12.3.
Change-Id: Id343531b408d42ac45f10c76f60e85bdb977f91e
Reviewed-on: https://go-review.googlesource.com/37582
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/math/bits/bits_impl.go')
| -rw-r--r-- | src/math/bits/bits_impl.go | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/src/math/bits/bits_impl.go b/src/math/bits/bits_impl.go index cf5a12af2b..0a1d8d7795 100644 --- a/src/math/bits/bits_impl.go +++ b/src/math/bits/bits_impl.go @@ -65,25 +65,3 @@ func ntz64(x uint64) int { // (Knuth, volume 4, section 7.3.1) return int(deBruijn64tab[(x&-x)*deBruijn64>>(64-6)]) } - -func blen(x uint64) (i int) { - for ; x >= 1<<(16-1); x >>= 16 { - i += 16 - } - if x >= 1<<(8-1) { - x >>= 8 - i += 8 - } - if x >= 1<<(4-1) { - x >>= 4 - i += 4 - } - if x >= 1<<(2-1) { - x >>= 2 - i += 2 - } - if x >= 1<<(1-1) { - i++ - } - return -} |
