@@ -1261,20 +1261,20 @@ relate Nil t2 = Prefix
1261
1261
relate t1 Nil = FlipPrefix
1262
1262
relate t1@ (Tip p1 bm1) t2@ (Tip p2 bm2) = relateTipTip t1 t2
1263
1263
relate t1@ (Bin p1 m1 l1 r1) t2@ (Bin p2 m2 l2 r2)
1264
- | succUpperbound t1 <= lowerbound t2 = Less
1265
- | lowerbound t1 >= succUpperbound t2 = Greater
1264
+ | upperbound t1 < lowerbound t2 = Less
1265
+ | lowerbound t1 > upperbound t2 = Greater
1266
1266
| otherwise = case compare (natFromInt m1) (natFromInt m2) of
1267
1267
GT -> combine_left (relate l1 t2)
1268
1268
EQ -> combine (relate l1 l2) (relate r1 r2)
1269
1269
LT -> combine_right (relate t1 l2)
1270
1270
relate t1@ (Bin p1 m1 l1 r1) t2@ (Tip p2 _)
1271
- | succUpperbound t1 <= lowerbound t2 = Less
1272
- | lowerbound t1 >= succUpperbound t2 = Greater
1271
+ | upperbound t1 < lowerbound t2 = Less
1272
+ | lowerbound t1 > upperbound t2 = Greater
1273
1273
| 0 == (m1 .&. p2) = combine_left (relate l1 t2)
1274
1274
| otherwise = Less
1275
1275
relate t1@ (Tip p1 _) t2@ (Bin p2 m2 l2 r2)
1276
- | succUpperbound t1 <= lowerbound t2 = Less
1277
- | lowerbound t1 >= succUpperbound t2 = Greater
1276
+ | upperbound t1 < lowerbound t2 = Less
1277
+ | lowerbound t1 > upperbound t2 = Greater
1278
1278
| 0 == (p1 .&. m2) = combine_right (relate t1 l2)
1279
1279
| otherwise = Greater
1280
1280
@@ -1343,12 +1343,11 @@ lowerbound :: IntSet -> Int
1343
1343
lowerbound (Tip p _) = p
1344
1344
lowerbound (Bin p _ _ _) = p
1345
1345
1346
- -- | this is one more than the actual upper bound (to save one operation)
1347
- -- shall only be applied to non-mixed non-Nil trees
1348
- succUpperbound :: IntSet -> Int
1349
- {-# INLINE succUpperbound #-}
1350
- succUpperbound (Tip p _) = p + wordSize
1351
- succUpperbound (Bin p m _ _) = p + shiftL m 1
1346
+ -- | shall only be applied to non-mixed non-Nil trees
1347
+ upperbound :: IntSet -> Int
1348
+ {-# INLINE upperbound #-}
1349
+ upperbound (Tip p _) = p + (wordSize - 1 )
1350
+ upperbound (Bin p m _ _) = p + (shiftL m 1 - 1 )
1352
1351
1353
1352
-- | split a set into subsets of negative and non-negative elements
1354
1353
splitSign :: IntSet -> (IntSet ,IntSet )
0 commit comments