From: Josh Bleecher Snyder Date: Tue, 5 Jul 2016 17:33:50 +0000 (-0700) Subject: math/big: use array instead of slice for deBruijn lookups X-Git-Tag: go1.8beta1~1884 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3357a02b74fea42c3348de83af81900c6623f584;p=gostls13.git 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 Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/math/big/nat.go b/src/math/big/nat.go index 2e65d2a7ef..b06df1c5f1 100644 --- a/src/math/big/nat.go +++ b/src/math/big/nat.go @@ -650,14 +650,14 @@ func (x nat) bitLen() int { 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, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, } 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, 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,