mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
Use binary literals for xor chunk encoding
An opinionated cosmetic change, but since go 1.13 we have this fancy 0b.... literals so we don't need to write hex and comment the binary value. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
parent
263847e64a
commit
40126a8494
|
@ -178,16 +178,16 @@ func (a *xorAppender) Append(t int64, v float64) {
|
||||||
case dod == 0:
|
case dod == 0:
|
||||||
a.b.writeBit(zero)
|
a.b.writeBit(zero)
|
||||||
case bitRange(dod, 14):
|
case bitRange(dod, 14):
|
||||||
a.b.writeBits(0x02, 2) // '10'
|
a.b.writeBits(0b10, 2)
|
||||||
a.b.writeBits(uint64(dod), 14)
|
a.b.writeBits(uint64(dod), 14)
|
||||||
case bitRange(dod, 17):
|
case bitRange(dod, 17):
|
||||||
a.b.writeBits(0x06, 3) // '110'
|
a.b.writeBits(0b110, 3)
|
||||||
a.b.writeBits(uint64(dod), 17)
|
a.b.writeBits(uint64(dod), 17)
|
||||||
case bitRange(dod, 20):
|
case bitRange(dod, 20):
|
||||||
a.b.writeBits(0x0e, 4) // '1110'
|
a.b.writeBits(0b1110, 4)
|
||||||
a.b.writeBits(uint64(dod), 20)
|
a.b.writeBits(uint64(dod), 20)
|
||||||
default:
|
default:
|
||||||
a.b.writeBits(0x0f, 4) // '1111'
|
a.b.writeBits(0b1111, 4)
|
||||||
a.b.writeBits(uint64(dod), 64)
|
a.b.writeBits(uint64(dod), 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,15 +344,15 @@ func (it *xorIterator) Next() bool {
|
||||||
var sz uint8
|
var sz uint8
|
||||||
var dod int64
|
var dod int64
|
||||||
switch d {
|
switch d {
|
||||||
case 0x00:
|
case 0b0:
|
||||||
// dod == 0
|
// dod == 0
|
||||||
case 0x02:
|
case 0b10:
|
||||||
sz = 14
|
sz = 14
|
||||||
case 0x06:
|
case 0b110:
|
||||||
sz = 17
|
sz = 17
|
||||||
case 0x0e:
|
case 0b1110:
|
||||||
sz = 20
|
sz = 20
|
||||||
case 0x0f:
|
case 0b1111:
|
||||||
// Do not use fast because it's very unlikely it will succeed.
|
// Do not use fast because it's very unlikely it will succeed.
|
||||||
bits, err := it.br.readBits(64)
|
bits, err := it.br.readBits(64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue