Re-use 'keys' in ReadOffsetTable (#645)
* Re-use 'keys' in ReadOffsetTable Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> * Add comment Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
This commit is contained in:
parent
d230c67aa1
commit
8dfa537843
|
@ -781,9 +781,13 @@ func ReadOffsetTable(bs ByteSlice, off uint64, f func([]string, uint64) error) e
|
|||
d := encoding.NewDecbufAt(bs, int(off), castagnoliTable)
|
||||
cnt := d.Be32()
|
||||
|
||||
// The Postings offset table takes only 2 keys per entry (name and value of label),
|
||||
// and the LabelIndices offset table takes only 1 key per entry (a label name).
|
||||
// Hence setting the size to max of both, i.e. 2.
|
||||
keys := make([]string, 0, 2)
|
||||
for d.Err() == nil && d.Len() > 0 && cnt > 0 {
|
||||
keyCount := d.Uvarint()
|
||||
keys := make([]string, 0, keyCount)
|
||||
keys = keys[:0]
|
||||
|
||||
for i := 0; i < keyCount; i++ {
|
||||
keys = append(keys, d.UvarintStr())
|
||||
|
|
Loading…
Reference in New Issue