diff --git a/Data/HashMap/Internal.hs b/Data/HashMap/Internal.hs index e9b6a938..20d16c86 100644 --- a/Data/HashMap/Internal.hs +++ b/Data/HashMap/Internal.hs @@ -2101,9 +2101,9 @@ filterMapAux onLeaf onColl = go ch <- A.read mary 0 case ch of t | isLeafOrCollision t -> return t - _ -> BitmapIndexed b <$> A.trim mary 1 + _ -> BitmapIndexed b <$> (A.unsafeFreeze =<< A.shrink mary 1) _ -> do - ary2 <- A.trim mary j + ary2 <- A.unsafeFreeze =<< A.shrink mary j return $! if j == maxChildren then Full ary2 else BitmapIndexed b ary2 @@ -2130,7 +2130,7 @@ filterMapAux onLeaf onColl = go return $! Leaf h l _ | i == j -> do ary2 <- A.unsafeFreeze mary return $! Collision h ary2 - | otherwise -> do ary2 <- A.trim mary j + | otherwise -> do ary2 <- A.unsafeFreeze =<< A.shrink mary j return $! Collision h ary2 | Just el <- onColl $! A.index ary i = A.write mary j el >> step ary mary (i+1) (j+1) n diff --git a/Data/HashMap/Internal/Array.hs b/Data/HashMap/Internal/Array.hs index 85c0d7ab..9590fea3 100644 --- a/Data/HashMap/Internal/Array.hs +++ b/Data/HashMap/Internal/Array.hs @@ -52,7 +52,6 @@ module Data.HashMap.Internal.Array , insertM , delete , sameArray1 - , trim , unsafeFreeze , unsafeThaw @@ -60,6 +59,7 @@ module Data.HashMap.Internal.Array , run , copy , copyM + , cloneM -- * Folds , foldl @@ -318,11 +318,6 @@ cloneM _mary@(MArray mary#) _off@(I# off#) _len@(I# len#) = case cloneSmallMutableArray# mary# off# len# s of (# s', mary'# #) -> (# s', MArray mary'# #) --- | Create a new array of the @n@ first elements of @mary@. -trim :: MArray s a -> Int -> ST s (Array a) -trim mary n = cloneM mary 0 n >>= unsafeFreeze -{-# INLINE trim #-} - -- | \(O(n)\) Insert an element at the given position in this array, -- increasing its size by one. insert :: Array e -> Int -> e -> Array e