Skip to content

Commit

Permalink
TSDB: eliminate one yolostring
Browse files Browse the repository at this point in the history
When the only use of a []byte->string conversion is as a map key, Go
doesn't allocate.

Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed Nov 26, 2024
1 parent e98c19c commit ca3119b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tsdb/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand All @@ -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))
}
Expand Down

0 comments on commit ca3119b

Please sign in to comment.