From 19028bdd18483689a3743639fa89d272cbb96c7b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 17 Feb 2017 15:02:49 -0800 Subject: math/bits: faster Rotate functions, added respective benchmarks Measured on 2.3 GHz Intel Core i7, running maxOS 10.12.3. benchmark old ns/op new ns/op delta BenchmarkRotateLeft-8 7.87 7.00 -11.05% BenchmarkRotateLeft8-8 8.41 4.52 -46.25% BenchmarkRotateLeft16-8 8.07 4.55 -43.62% BenchmarkRotateLeft32-8 8.36 4.73 -43.42% BenchmarkRotateLeft64-8 7.93 4.78 -39.72% BenchmarkRotateRight-8 8.23 6.72 -18.35% BenchmarkRotateRight8-8 8.76 4.39 -49.89% BenchmarkRotateRight16-8 9.07 4.44 -51.05% BenchmarkRotateRight32-8 8.85 4.46 -49.60% BenchmarkRotateRight64-8 8.11 4.43 -45.38% Change-Id: I79ea1e9e6fc65f95794a91f860a911efed3aa8a1 Reviewed-on: https://go-review.googlesource.com/37219 Reviewed-by: Matthew Dempsky --- src/math/bits/bits_impl.go | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/math/bits/bits_impl.go') diff --git a/src/math/bits/bits_impl.go b/src/math/bits/bits_impl.go index c7834106c8..e7c1a8a5dc 100644 --- a/src/math/bits/bits_impl.go +++ b/src/math/bits/bits_impl.go @@ -74,17 +74,6 @@ func ntz64(x uint64) int { return int(deBruijn64tab[(x&-x)*deBruijn64>>(64-6)]) } -func pos(k int) uint { - if k < 0 { - panic("negative rotation count") - } - return uint(k) -} - -func rot(x uint64, size, k uint) uint64 { - return x<>(size-k)&(1<= 1<<(16-1); x >>= 16 { i += 16 -- cgit v1.3-5-g9baa