From ca3119bd24c451851c15e47642e85b449552d85c Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 25 Nov 2024 16:51:55 +0000 Subject: [PATCH] TSDB: eliminate one yolostring When the only use of a []byte->string conversion is as a map key, Go doesn't allocate. Signed-off-by: Bryan Boreham --- tsdb/index/index.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tsdb/index/index.go b/tsdb/index/index.go index 69ecd59b3..911b1a6ec 100644 --- a/tsdb/index/index.go +++ b/tsdb/index/index.go @@ -610,10 +610,10 @@ func (w *Writer) writeLabelIndices() error { values := []uint32{} for d.Err() == nil && cnt > 0 { cnt-- - d.Uvarint() // Keycount. - name := d.UvarintBytes() // Label name. - value := yoloString(d.UvarintBytes()) // Label value. - d.Uvarint64() // Offset. + d.Uvarint() // Keycount. + name := d.UvarintBytes() // Label name. + value := d.UvarintBytes() // Label value. + d.Uvarint64() // Offset. if len(name) == 0 { continue // All index is ignored. } @@ -626,7 +626,7 @@ func (w *Writer) writeLabelIndices() error { values = values[:0] } current = name - sid, ok := w.symbolCache[value] + sid, ok := w.symbolCache[string(value)] if !ok { return fmt.Errorf("symbol entry for %q does not exist", string(value)) }