File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -1840,30 +1840,28 @@ intersectionArrayBy f !b1 !b2 !ary1 !ary2
1840
1840
| b1 .&. b2 == 0 = Empty
1841
1841
| otherwise = runST $ do
1842
1842
mary <- A. new_ $ popCount bIntersect
1843
- -- iterate over nonzero bits of b1 .| . b2
1844
- let go ! i ! i1 ! i2 ! b ! bFinal
1843
+ -- iterate over nonzero bits of b1 .& . b2
1844
+ let go ! i ! b ! bFinal
1845
1845
| b == 0 = pure (i, bFinal)
1846
- | testBit $ b1 .&. b2 = do
1846
+ | otherwise = do
1847
1847
x1 <- A. indexM ary1 i1
1848
1848
x2 <- A. indexM ary2 i2
1849
1849
case f x1 x2 of
1850
- Empty -> go i (i1 + 1 ) (i2 + 1 ) b' (bFinal .&. complement m)
1850
+ Empty -> go i b' (bFinal .&. complement m)
1851
1851
_ -> do
1852
1852
A. write mary i $! f x1 x2
1853
- go (i + 1 ) (i1 + 1 ) (i2 + 1 ) b' bFinal
1854
- | testBit b1 = go i (i1 + 1 ) i2 b' bFinal
1855
- | otherwise = go i i1 (i2 + 1 ) b' bFinal
1853
+ go (i + 1 ) b' bFinal
1856
1854
where
1857
1855
m = 1 `unsafeShiftL` countTrailingZeros b
1858
- testBit x = x .&. m /= 0
1856
+ i1 = sparseIndex b1 m
1857
+ i2 = sparseIndex b2 m
1859
1858
b' = b .&. complement m
1860
- (len, bFinal) <- go 0 0 0 bCombined bIntersect
1859
+ (len, bFinal) <- go 0 bIntersect bIntersect
1861
1860
case len of
1862
1861
0 -> pure Empty
1863
1862
1 -> A. read mary 0
1864
1863
_ -> bitmapIndexedOrFull bFinal <$> (A. unsafeFreeze =<< A. shrink mary len)
1865
1864
where
1866
- bCombined = b1 .|. b2
1867
1865
bIntersect = b1 .&. b2
1868
1866
{-# INLINE intersectionArrayBy #-}
1869
1867
You can’t perform that action at this time.
0 commit comments