Use cloneSliceUnsafeAs in cloneAs
commited07663f8cdb7c49dba9befc31e4f693ff8e48c9
authorHarendra Kumar <harendra@composewell.com>
dateSun 26 Nov 2023, 02:37 (3 years ago)
parent62c12a6
core/src/Streamly/Internal/Data/MutArray/Type.hs+2−2
@@ -2103,8 +2103,8 @@ cloneAs ps src =
21032103 liftIO $ do
21042104 let startSrc = arrStart src
21052105 srcLen = arrEnd src - startSrc
2106− newArrContents <- Unboxed.newBytesAs ps srcLen
2107− putSliceUnsafe (arrContents src) startSrc newArrContents 0 srcLen
2106+ newArrContents <-
2107+ Unboxed.cloneSliceUnsafeAs ps startSrc srcLen (arrContents src)
21082108 return $ MutArray newArrContents 0 srcLen srcLen
21092109
21102110{-# INLINE clone #-}
core/src/Streamly/Internal/Data/Serialize/Type.hs+1
@@ -283,6 +283,7 @@ instance Serialize (Array a) where
283283 $ "deserializeAt: accessing array at offset = "
284284 ++ show (off2 - 1)
285285 ++ " max valid offset = " ++ show (len - 1)
286+ -- XXX Use MutByteArray.cloneSliceUnsafe
286287 let slice = MutArray.MutArray arr off1 off2 off2
287288 newArr <- MutArray.clone slice
288289 pure (off2, Array.unsafeFreeze newArr)