0
0
Fork 0

Merge pull request #564 from steveyen/master

optimmize heap collector Final() for large counts
This commit is contained in:
Marty Schoch 2017-04-29 19:48:52 -04:00 committed by GitHub
commit 15cb7a505a
1 changed files with 6 additions and 11 deletions

View File

@ -58,17 +58,12 @@ func (c *collectStoreHeap) Final(skip int, fixup collectorFixup) (search.Documen
return make(search.DocumentMatchCollection, 0), nil
}
rv := make(search.DocumentMatchCollection, size)
for count > 0 {
count--
if count >= skip {
size--
doc := heap.Pop(c).(*search.DocumentMatch)
rv[size] = doc
err := fixup(doc)
if err != nil {
return nil, err
}
for i := size - 1; i >= 0; i-- {
doc := heap.Pop(c).(*search.DocumentMatch)
rv[i] = doc
err := fixup(doc)
if err != nil {
return nil, err
}
}
return rv, nil