Browse Source

Use Go 1.9 math/bits implementation for counting leading / trailing zeros

pull/5805/head
Daniel Swarbrick 7 years ago
parent
commit
0585ab3fcd
  1. 7
      chunks/xor.go

7
chunks/xor.go

@ -46,8 +46,7 @@ package chunks
import (
"encoding/binary"
"math"
bits "github.com/dgryski/go-bits"
"math/bits"
)
// XORChunk holds XOR encoded sample data.
@ -197,8 +196,8 @@ func (a *xorAppender) writeVDelta(v float64) {
}
a.b.writeBit(one)
leading := uint8(bits.Clz(vDelta))
trailing := uint8(bits.Ctz(vDelta))
leading := uint8(bits.LeadingZeros64(vDelta))
trailing := uint8(bits.TrailingZeros64(vDelta))
// Clamp number of leading zeros to avoid overflow when encoding.
if leading >= 32 {

Loading…
Cancel
Save