Skip to content

Commit

Permalink
always lookup name symbol first
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Sep 21, 2023
1 parent 387bd8d commit 2c1f79a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/block/indexheader/binary_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,15 +925,6 @@ func (r *BinaryReader) postingsOffset(name string, values ...string) ([]index.Ra
}

func (r *BinaryReader) LookupSymbol(o uint32) (string, error) {
cacheIndex := o % valueSymbolsCacheSize
r.valueSymbolsMx.Lock()
if cached := r.valueSymbols[cacheIndex]; cached.index == o && cached.symbol != "" {
v := cached.symbol
r.valueSymbolsMx.Unlock()
return v, nil
}
r.valueSymbolsMx.Unlock()

if s, ok := r.nameSymbols[o]; ok {
return s, nil
}
Expand All @@ -944,6 +935,15 @@ func (r *BinaryReader) LookupSymbol(o uint32) (string, error) {
o += headerLen - index.HeaderLen
}

cacheIndex := o % valueSymbolsCacheSize
r.valueSymbolsMx.Lock()
if cached := r.valueSymbols[cacheIndex]; cached.index == o && cached.symbol != "" {
v := cached.symbol
r.valueSymbolsMx.Unlock()
return v, nil
}
r.valueSymbolsMx.Unlock()

s, err := r.symbols.Lookup(o)
if err != nil {
return s, err
Expand Down

0 comments on commit 2c1f79a

Please sign in to comment.