on master help sign in
Fix a fusion issue failing in bench:Unicode.Stream
commitd9abfa1d873cb1b407e63ce917c99944787a9cb5 authorAdithya Kumar <adithya@composewell.com> dateSat 31 Jul 2021, 09:00 (5 years ago) parentf21fbbd
1 file changed+4−3
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+4−3
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+4−3
@@ -332,13 +332,13 @@ snoc arr@Array {..} x =
332332-- | Reallocate the array to the specified size in bytes. If the size is less
333333-- than the original array the array gets truncated.
334334{-# NOINLINE reallocAligned #-}
335−reallocAligned :: MonadIO m => Int -> Int -> Array a -> m (Array a)
335+reallocAligned :: Int -> Int -> Array a -> IO (Array a)
336336reallocAligned alignSize newSize Array{..} = do
337337 assert (aEnd <= aBound) (return ())
338338 let oldStart = unsafeForeignPtrToPtr aStart
339339 let size = aEnd `minusPtr` oldStart
340− newPtr <- liftIO $ Malloc.mallocForeignPtrAlignedBytes newSize alignSize
341− unsafeWithForeignPtrM newPtr $ \pNew -> liftIO $ do
340+ newPtr <- Malloc.mallocForeignPtrAlignedBytes newSize alignSize
341+ unsafeWithForeignPtr newPtr $ \pNew -> do
342342 memcpy (castPtr pNew) (castPtr oldStart) size
343343 touchForeignPtr aStart
344344 return $ Array
@@ -353,6 +353,7 @@ realloc :: forall m a. (MonadIO m, Storable a) => Int -> Array a -> m (Array a)
353353realloc i arr = liftIO $ reallocAligned (alignment (undefined :: a)) i arr
354354
355355-- | Remove the free space from an Array.
356+{-# INLINE shrinkToFit #-}
356357shrinkToFit :: (MonadIO m, Storable a) => Array a -> m (Array a)
357358shrinkToFit arr@Array{..} = do
358359 assert (aEnd <= aBound) (return ())