on master help sign in
Do not make a copy of the array in breakOn
commit51d99c947b5890b235ff79d06cfafb4a48c45661 authorHarendra Kumar <harendra@composewell.com> dateTue 26 Dec 2023, 09:31 (3 years ago) parent7a8b362
1 file changed+2−3
core/src/Streamly/Internal/Data/MutArray/Type.hs+2−3
core/src/Streamly/Internal/Data/MutArray/Type.hs+2−3
@@ -2290,10 +2290,9 @@ spliceExp = spliceWith (\l1 l2 -> max (l1 * 2) (l1 + l2))
22902290{-# INLINE breakOn #-}
22912291breakOn :: MonadIO m
22922292 => Word8 -> MutArray Word8 -> m (MutArray Word8, Maybe (MutArray Word8))
2293−breakOn sep arr@MutArray{..} = asPtrUnsafe arr $ \p -> liftIO $ do
2294− -- XXX Instead of using asPtrUnsafe (pinning memory) we can pass unlifted
2295− -- Addr# to memchr and it should be safe (from ghc 8.4).
2293+breakOn sep arr@MutArray{..} = asUnpinnedPtrUnsafe arr $ \p -> liftIO $ do
22962294 -- XXX We do not need memchr here, we can use a Haskell equivalent.
2295+ -- Need efficient stream based primitives that work on Word64.
22972296 loc <- c_memchr p sep (fromIntegral $ byteLength arr)
22982297 let sepIndex = loc `minusPtr` p
22992298 return $