Commit 3357a02b authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

math/big: use array instead of slice for deBruijn lookups

This allows the compiler to remove a bounds check.

math/big/nat.go:681: index bounds check elided
math/big/nat.go:683: index bounds check elided

Change-Id: Ieecb89ec5e988761b06764bd671672015cd58e9d
Reviewed-on: https://go-review.googlesource.com/26663
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4e24e1d9
...@@ -650,14 +650,14 @@ func (x nat) bitLen() int { ...@@ -650,14 +650,14 @@ func (x nat) bitLen() int {
const deBruijn32 = 0x077CB531 const deBruijn32 = 0x077CB531
var deBruijn32Lookup = []byte{ var deBruijn32Lookup = [...]byte{
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9,
} }
const deBruijn64 = 0x03f79d71b4ca8b09 const deBruijn64 = 0x03f79d71b4ca8b09
var deBruijn64Lookup = []byte{ var deBruijn64Lookup = [...]byte{
0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,
62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,
63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment