on master help sign in
Rename spliceTwo to spliceCopy
commitd20dcf44a17f62a93cacee32d8223920216c095c authorHarendra Kumar <harendra@composewell.com> dateSat 16 Oct 2021, 11:19 (5 years ago) parent83d6019
4 files changed+14−14
src/Streamly/Internal/Data/Array/Foreign/Mut.hs+1−1 src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+4−4 src/Streamly/Internal/Data/Array/Foreign/Type.hs+6−6 src/Streamly/Internal/Data/Array/Stream/Foreign.hs+3−3
src/Streamly/Internal/Data/Array/Foreign/Mut.hs+1−1
@@ -67,7 +67,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut
6767 -- * Combining
6868 , splice
6969 , spliceExp
70− , spliceTwo
70+ , spliceCopy
7171
7272 -- * Splitting
7373 , breakOn
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+4−4
@@ -97,7 +97,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
9797 , spliceWith
9898 , splice
9999 , spliceExp
100− , spliceTwo
100+ , spliceCopy
101101
102102 -- * Splitting
103103 , breakOn
@@ -1367,9 +1367,9 @@ fromList xs = fromStreamD $ D.fromList xs
13671367-------------------------------------------------------------------------------
13681368
13691369-- | Copy two arrays into a newly allocated array.
1370−{-# INLINE spliceTwo #-}
1371−spliceTwo :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
1372−spliceTwo arr1 arr2 = do
1370+{-# INLINE spliceCopy #-}
1371+spliceCopy :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
1372+spliceCopy arr1 arr2 = do
13731373 let src1 = unsafeForeignPtrToPtr (aStart arr1)
13741374 src2 = unsafeForeignPtrToPtr (aStart arr2)
13751375 len1 = aEnd arr1 `minusPtr` src1
src/Streamly/Internal/Data/Array/Foreign/Type.hs+6−6
@@ -22,7 +22,7 @@ module Streamly.Internal.Data.Array.Foreign.Type
2222 , unsafeThaw
2323
2424 -- * Construction
25− , spliceTwo
25+ , splice
2626
2727 , fromPtr
2828 , fromAddr#
@@ -194,10 +194,10 @@ unsafeThaw (Array as ae) = MA.Array as ae ae
194194-------------------------------------------------------------------------------
195195
196196-- Splice two immutable arrays creating a new array.
197−{-# INLINE spliceTwo #-}
198−spliceTwo :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
199−spliceTwo arr1 arr2 =
200− unsafeFreeze <$> MA.spliceTwo (unsafeThaw arr1) (unsafeThaw arr2)
197+{-# INLINE splice #-}
198+splice :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
199+splice arr1 arr2 =
200+ unsafeFreeze <$> MA.splice (unsafeThaw arr1) (unsafeThaw arr2)
201201
202202-- | Create an 'Array' of the given number of elements of type @a@ from a read
203203-- only pointer @Ptr a@. The pointer is not freed when the array is garbage
@@ -671,7 +671,7 @@ instance Foldable Array where
671671-------------------------------------------------------------------------------
672672
673673instance Storable a => Semigroup (Array a) where
674− arr1 <> arr2 = unsafePerformIO $ spliceTwo arr1 arr2
674+ arr1 <> arr2 = unsafePerformIO $ splice arr1 arr2
675675
676676nullForeignPtr :: ForeignPtr a
677677nullForeignPtr = ForeignPtr nullAddr# (error "nullForeignPtr")
src/Streamly/Internal/Data/Array/Stream/Foreign.hs+3−3
@@ -265,7 +265,7 @@ _splitOn byte (D.Stream step state) = D.Stream step' (Initial state)
265265 case r of
266266 D.Yield arr s -> do
267267 (arr1, marr2) <- A.breakOn byte arr
268− buf' <- A.spliceTwo buf arr1
268+ buf' <- A.splice buf arr1
269269 return $ case marr2 of
270270 Nothing -> D.Skip (Buffering s buf')
271271 Just x -> D.Skip (Yielding buf' (Splitting s x))
@@ -295,7 +295,7 @@ splitOn
295295 -> t m (Array Word8)
296296 -> t m (Array Word8)
297297splitOn byte s =
298− fromStreamD $ D.splitInnerBy (A.breakOn byte) A.spliceTwo $ toStreamD s
298+ fromStreamD $ D.splitInnerBy (A.breakOn byte) A.splice $ toStreamD s
299299
300300{-# INLINE splitOnSuffix #-}
301301splitOnSuffix
@@ -305,7 +305,7 @@ splitOnSuffix
305305 -> t m (Array Word8)
306306-- splitOn byte s = fromStreamD $ A.splitOn byte $ toStreamD s
307307splitOnSuffix byte s =
308− fromStreamD $ D.splitInnerBySuffix (A.breakOn byte) A.spliceTwo $ toStreamD s
308+ fromStreamD $ D.splitInnerBySuffix (A.breakOn byte) A.splice $ toStreamD s
309309
310310-------------------------------------------------------------------------------
311311-- Elimination - Running folds