From 19807ff3a72ed6a2d9d55079af44eae466b16dac Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Sat, 9 Mar 2019 21:51:08 -0600 Subject: [PATCH] use num containers to decide which direction to union avoids doing a potentially expensive f.storage.Count() --- fragment.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fragment.go b/fragment.go index c09461470..0c4ff5dd6 100644 --- a/fragment.go +++ b/fragment.go @@ -1750,15 +1750,11 @@ func (f *fragment) importRoaring(data []byte, clear bool) error { if clear { bm = f.storage.Difference(bm) + } else if f.storage.Containers.Size() >= bm.Containers.Size() { + f.storage.UnionInPlace(bm) + bm = f.storage } else { - if cnt := f.storage.Count(); cnt > 0 { - if incomingCnt > int(cnt) { - bm.UnionInPlace(f.storage) - } else { - f.storage.UnionInPlace(bm) - bm = f.storage - } - } + bm.UnionInPlace(f.storage) } for _, rowID := range rowSet {