[commit: packages/containers] master, revert-408-bugfix_394: enhanced the bitmap restriction in restrictKeys to also mask out too-large keys (c61287f)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:48:13 UTC 2017


Repository : ssh://git@git.haskell.org/containers

On branches: master,revert-408-bugfix_394
Link       : http://git.haskell.org/packages/containers.git/commitdiff/c61287fa7255ae7e63f12f883def3fc80a2b2f36

>---------------------------------------------------------------

commit c61287fa7255ae7e63f12f883def3fc80a2b2f36
Author: wren romano <wren at community.haskell.org>
Date:   Mon Feb 13 21:23:59 2017 -0800

    enhanced the bitmap restriction in restrictKeys to also mask out too-large keys


>---------------------------------------------------------------

c61287fa7255ae7e63f12f883def3fc80a2b2f36
 Data/IntMap/Internal.hs | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Data/IntMap/Internal.hs b/Data/IntMap/Internal.hs
index fd02e19..26c42b3 100644
--- a/Data/IntMap/Internal.hs
+++ b/Data/IntMap/Internal.hs
@@ -1131,20 +1131,20 @@ restrictKeys t1@(Bin _ _ _ _) (IntSet.Tip p2 bm2) =
             -- The bitmap-index of the smallest key possibly in @t1'@.
             -- N.B., we must mask @p1@ because the low bits aren't
             -- guaranteed to be clear!
-            s1 :: Int
-            s1 = mask p1 m1 .&. IntSet.suffixBitMask
-            -- @s1@ as a bitmap.
-            s1_bitmap :: IntSetBitMap
-            s1_bitmap = shiftLL 1 s1
-            -- Bitmap of all keys strictly less than @s1 at .
-            bitsLT_s1 :: IntSetBitMap
-            bitsLT_s1 = s1_bitmap - 1
-            -- Bitmap of all keys greater than or equal to @s1 at .
-            bitsGE_s1 :: IntSetBitMap
-            bitsGE_s1 = complement bitsLT_s1
+            minkey :: Prefix
+            minkey = mask p1 m1 .&. IntSet.suffixBitMask
+            -- Bitmap of all keys greater than or equal to @minkey at .
+            largeEnoughKeys :: IntSetBitMap
+            largeEnoughKeys = complement (shiftLL 1 minkey - 1)
+            -- The bitmap for the largest key possibly in @t1'@.
+            maxbit :: IntSetBitMap
+            maxbit = shiftLL 1 (m1 .|. (minkey - 1))
+            -- Bitmap of all keys less than or equal to @maxkey at .
+            smallEnoughKeys :: IntSetBitMap
+            smallEnoughKeys = maxbit .|. (maxbit - 1)
             -- Restrict @bm2@ to keys which could possibly occur in @t1'@.
             bm2' :: IntSetBitMap
-            bm2' = bm2 .&. bitsGE_s1
+            bm2' = bm2 .&. largeEnoughKeys .&. smallEnoughKeys
         in restrictBM t1' p2 bm2 (IntSet.suffixBitMask + 1)
     t1' -> t1'
 restrictKeys (Bin _ _ _ _) IntSet.Nil = Nil



More information about the ghc-commits mailing list