@@ -1477,6 +1477,8 @@ isSubmapOfBy comp = go 0
1477
1477
-- Insert the collision into a bitmap indexed node and recurse.
1478
1478
go s t1@ (BitmapIndexed {}) t2@ (Collision h2 _) =
1479
1479
go s t1 (BitmapIndexed (mask h2 s) (A. singleton t2))
1480
+ go s t1@ (BitmapIndexed {}) t2@ (Leaf h2 _) =
1481
+ go s t1 (BitmapIndexed (mask h2 s) (A. singleton t2))
1480
1482
go s t1@ (Full {}) t2@ (Collision h2 _) =
1481
1483
go s t1 (BitmapIndexed (mask h2 s) (A. singleton t2))
1482
1484
@@ -1491,10 +1493,9 @@ isSubmapOfBy comp = go 0
1491
1493
go s (Full ls1) (BitmapIndexed b2 ls2) =
1492
1494
submapBitmapIndexed (go (s+ bitsPerSubkey)) fullNodeMask ls1 b2 ls2
1493
1495
1494
- -- A collision, bitmap indexed an full node always contain at least two
1495
- -- entries. Hence it cannot be a map of a leaf.
1496
+ -- Collision and Full nodes always contain at least two entries. Hence it
1497
+ -- cannot be a map of a leaf.
1496
1498
go _ (Collision {}) (Leaf {}) = False
1497
- go _ (BitmapIndexed {}) (Leaf {}) = False
1498
1499
go _ (Full {}) (Leaf {}) = False
1499
1500
1500
1501
@@ -2189,12 +2190,10 @@ updateOrConcatWithKey f ary1 ary2 = A.run $ do
2189
2190
2190
2191
-- | /O(n*m)/ Check if the first array is a subset of the second array.
2191
2192
subsetArray :: Eq k => (v1 -> v2 -> Bool ) -> A. Array (Leaf k v1 ) -> A. Array (Leaf k v2 ) -> Bool
2192
- subsetArray cmpV ary1 ary2 = A. length ary1 <= A. length ary2 && go 0 ( A. length ary1)
2193
+ subsetArray cmpV ary1 ary2 = A. length ary1 <= A. length ary2 && A. all inAry2 ary1
2193
2194
where
2194
- go ! i n
2195
- | i >= n = True
2196
- | otherwise = let (L k1 v1) = A. index ary1 i
2197
- in lookupInArrayCont (\ _ -> False ) (\ v2 _ -> cmpV v1 v2 && go (i+ 1 ) n) k1 ary2
2195
+ inAry2 (L k1 v1) = lookupInArrayCont (\ _ -> False ) (\ v2 _ -> cmpV v1 v2) k1 ary2
2196
+ {-# INLINE inAry2 #-}
2198
2197
2199
2198
------------------------------------------------------------------------
2200
2199
-- Manually unrolled loops
0 commit comments