From ed33aea392185647ed34534edbec0bc355d80b5d Mon Sep 17 00:00:00 2001 From: beorn7 Date: Fri, 15 Oct 2021 20:33:14 +0200 Subject: [PATCH] Avoid redundant varint decoding in chunk appender construction Signed-off-by: beorn7 --- tsdb/chunkenc/histogram.go | 2 +- tsdb/chunkenc/xor.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tsdb/chunkenc/histogram.go b/tsdb/chunkenc/histogram.go index e0aa8f83b5..39bbbf2213 100644 --- a/tsdb/chunkenc/histogram.go +++ b/tsdb/chunkenc/histogram.go @@ -154,7 +154,7 @@ func (c *HistogramChunk) Appender() (Appender, error) { leading: it.leading, trailing: it.trailing, } - if binary.BigEndian.Uint16(a.b.bytes()) == 0 { + if it.numTotal == 0 { a.leading = 0xff } return a, nil diff --git a/tsdb/chunkenc/xor.go b/tsdb/chunkenc/xor.go index 21c35d3c1b..e3d2b89764 100644 --- a/tsdb/chunkenc/xor.go +++ b/tsdb/chunkenc/xor.go @@ -111,7 +111,7 @@ func (c *XORChunk) Appender() (Appender, error) { leading: it.leading, trailing: it.trailing, } - if binary.BigEndian.Uint16(a.b.bytes()) == 0 { + if it.numTotal == 0 { a.leading = 0xff } return a, nil