Skip to content

Commit e6e66f7

Browse files
committed
Remove pointer equality checks
1 parent 370ee24 commit e6e66f7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Data/HashMap/Internal.hs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,18 +2331,22 @@ disjointSubtrees _ (Leaf hA (L kA _)) (Leaf hB (L kB _)) =
23312331
hA /= hB || kA /= kB
23322332
disjointSubtrees s (Leaf hA (L kA _)) b =
23332333
lookupCont (\_ -> True) (\_ _ -> False) hA kA s b
2334-
disjointSubtrees s (BitmapIndexed bmA aryA) (BitmapIndexed bmB aryB)
2335-
-- TODO: Try removing this check and just rely on disjointArrays.
2336-
| bmA .&. bmB == 0 = True
2337-
| aryA `A.unsafeSameArray` aryB = False
2338-
| otherwise = disjointArrays s bmA aryA bmB aryB
2334+
disjointSubtrees s (BitmapIndexed bmA aryA) (BitmapIndexed bmB aryB) =
2335+
-- We could do a pointer equality check here but it's probably not worth it
2336+
-- since it would save only O(1) extra work:
2337+
--
2338+
-- not (aryA `A.unsafeSameArray` aryB) &&
2339+
disjointArrays s bmA aryA bmB aryB
23392340
disjointSubtrees s (BitmapIndexed bmA aryA) (Full aryB) =
23402341
disjointArrays s bmA aryA fullBitmap aryB
23412342
disjointSubtrees s (Full aryA) (BitmapIndexed bmB aryB) =
23422343
disjointArrays s fullBitmap aryA bmB aryB
2343-
disjointSubtrees s (Full aryA) (Full aryB)
2344-
| aryA `A.unsafeSameArray` aryB = False
2345-
| otherwise = go (maxChildren - 1)
2344+
disjointSubtrees s (Full aryA) (Full aryB) =
2345+
-- We could do a pointer equality check here but it's probably not worth it
2346+
-- since it would save only O(1) extra work:
2347+
--
2348+
-- not (aryA `A.unsafeSameArray` aryB) &&
2349+
go (maxChildren - 1)
23462350
where
23472351
go i
23482352
| i < 0 = True

0 commit comments

Comments
 (0)