diff options
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/search/pool.go')
-rw-r--r-- | vendor/github.com/blevesearch/bleve/search/pool.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/vendor/github.com/blevesearch/bleve/search/pool.go b/vendor/github.com/blevesearch/bleve/search/pool.go index 043e53f82f..b9b52a613f 100644 --- a/vendor/github.com/blevesearch/bleve/search/pool.go +++ b/vendor/github.com/blevesearch/bleve/search/pool.go @@ -37,13 +37,17 @@ func defaultDocumentMatchPoolTooSmall(p *DocumentMatchPool) *DocumentMatch { // pre-allocated to accommodate the requested number of DocumentMatch // instances func NewDocumentMatchPool(size, sortsize int) *DocumentMatchPool { - avail := make(DocumentMatchCollection, 0, size) + avail := make(DocumentMatchCollection, size) // pre-allocate the expected number of instances startBlock := make([]DocumentMatch, size) + startSorts := make([]string, size*sortsize) // make these initial instances available - for i := range startBlock { - startBlock[i].Sort = make([]string, 0, sortsize) - avail = append(avail, &startBlock[i]) + i, j := 0, 0 + for i < size { + avail[i] = &startBlock[i] + avail[i].Sort = startSorts[j:j] + i += 1 + j += sortsize } return &DocumentMatchPool{ avail: avail, |