mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-01-30 09:31:02 +07:00
19 lines
375 B
Go
19 lines
375 B
Go
// +build !go1.9
|
|
|
|
package fse
|
|
|
|
var deBruijnClz = [...]uint8{0, 9, 1, 10, 13, 21, 2, 29,
|
|
11, 14, 16, 18, 22, 25, 3, 30,
|
|
8, 12, 20, 28, 15, 17, 24, 7,
|
|
19, 27, 23, 6, 26, 5, 4, 31}
|
|
|
|
// highBits returns the highest set bit
|
|
func highBits(v uint32) (n uint32) {
|
|
v |= v >> 1
|
|
v |= v >> 2
|
|
v |= v >> 4
|
|
v |= v >> 8
|
|
v |= v >> 16
|
|
return uint32(deBruijnClz[(v*0x07C4ACDD)>>27])
|
|
}
|