mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
Merge pull request #198 from dswarbrick/master
Use Go 1.9 math/bits funcs for counting leading / trailing zeros
This commit is contained in:
commit
1bacdf8e33
|
@ -3,7 +3,7 @@ sudo: false
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.8.x
|
- 1.9.x
|
||||||
|
|
||||||
go_import_path: github.com/prometheus/tsdb
|
go_import_path: github.com/prometheus/tsdb
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,7 @@ package chunks
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"math"
|
"math"
|
||||||
|
"math/bits"
|
||||||
bits "github.com/dgryski/go-bits"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// XORChunk holds XOR encoded sample data.
|
// XORChunk holds XOR encoded sample data.
|
||||||
|
@ -197,8 +196,8 @@ func (a *xorAppender) writeVDelta(v float64) {
|
||||||
}
|
}
|
||||||
a.b.writeBit(one)
|
a.b.writeBit(one)
|
||||||
|
|
||||||
leading := uint8(bits.Clz(vDelta))
|
leading := uint8(bits.LeadingZeros64(vDelta))
|
||||||
trailing := uint8(bits.Ctz(vDelta))
|
trailing := uint8(bits.TrailingZeros64(vDelta))
|
||||||
|
|
||||||
// Clamp number of leading zeros to avoid overflow when encoding.
|
// Clamp number of leading zeros to avoid overflow when encoding.
|
||||||
if leading >= 32 {
|
if leading >= 32 {
|
||||||
|
|
Loading…
Reference in a new issue