MemPostings: allocate ListPostings once in PFALV (#15465)

Same as #15427 but for the new method added in #14144

Instead of allocating each ListPostings one by one, allocate them all in
one go.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
pull/15466/head
Oleg Zaytsev 2024-11-26 16:03:45 +01:00 committed by GitHub
parent 975d5d7357
commit 9aa6e041d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -454,10 +454,14 @@ func (p *MemPostings) PostingsForAllLabelValues(ctx context.Context, name string
e := p.m[name]
its := make([]Postings, 0, len(e))
lps := make([]ListPostings, len(e))
i := 0
for _, refs := range e {
if len(refs) > 0 {
its = append(its, NewListPostings(refs))
lps[i] = ListPostings{list: refs}
its = append(its, &lps[i])
}
i++
}
// Let the mutex go before merging.