Use ExpandPostings() in NewPostingsCloner()

We should reuse that method, not only because it saves code, but also
because that method is a good candidate to use a pool of slices some
day.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
Oleg Zaytsev 2021-10-13 15:26:36 +02:00
parent 8bc1b41795
commit 14cb8d8696
No known key found for this signature in database
GPG key ID: 7E9FE9FD48F512EF

View file

@ -807,11 +807,8 @@ type PostingsCloner struct {
// The instance provided shouldn't have been used before (no Next() calls should have been done)
// and it shouldn't be used once provided to the PostingsCloner.
func NewPostingsCloner(p Postings) *PostingsCloner {
var ids []uint64
for p.Next() {
ids = append(ids, p.At())
}
return &PostingsCloner{ids: ids, err: p.Err()}
ids, err := ExpandPostings(p)
return &PostingsCloner{ids: ids, err: err}
}
// Clone returns another independent Postings instance.