@@ -42,15 +42,12 @@ module Streamly.Internal.Data.Array.Mut.Type
4242 , nil
4343
4444 -- *** Uninitialized Arrays
45− , newPinned
46− , newPinnedBytes
47− , newAlignedPinned
45+ , pinnedNew
46+ , pinnedNewBytes
47+ , pinnedNewAligned
4848 , new
4949 , newArrayWith
5050
51− -- *** Initialized Arrays
52− , withNewArrayUnsafePinned
53−
5451 -- *** From streams
5552 , ArrayUnsafe (..)
5653 , writeNWithUnsafe
@@ -388,7 +385,7 @@ isPinned MutArray{..} = Unboxed.isPinned arrContents
388385-- files and arrays.
389386
390387-- GHC always guarantees word-aligned memory, alignment is important only when
391−-- we need more than that. See stg_newAlignedPinnedByteArrayzh and
388+-- we need more than that. See stg_pinnedNewAlignedByteArrayzh and
392389-- allocatePinned in GHC source.
393390
394391-- | @newArrayWith allocator alignment count@ allocates a new array of zero
@@ -441,22 +438,22 @@ newBytesAs ps bytes = do
441438-- 'Unboxed' instance of the type.
442439--
443440-- /Pre-release/
444−{-# INLINE newPinnedBytes #-}
445−newPinnedBytes :: MonadIO m =>
441+{-# INLINE pinnedNewBytes #-}
442+pinnedNewBytes :: MonadIO m =>
446443#ifdef DEVBUILD
447444 Unbox a =>
448445#endif
449446 Int -> m (MutArray a)
450−newPinnedBytes = newBytesAs Pinned
447+pinnedNewBytes = newBytesAs Pinned
451448
452449-- | Like 'newArrayWith' but using an allocator is a pinned memory allocator and
453450-- the alignment is dictated by the 'Unboxed' instance of the type.
454451--
455452-- /Internal/
456−{-# INLINE newAlignedPinned #-}
457−newAlignedPinned :: (MonadIO m, Unbox a) => Int -> Int -> m (MutArray a)
458−newAlignedPinned =
459− newArrayWith (\s a -> liftIO $ Unboxed.newAlignedPinnedBytes s a)
453+{-# INLINE pinnedNewAligned #-}
454+pinnedNewAligned :: (MonadIO m, Unbox a) => Int -> Int -> m (MutArray a)
455+pinnedNewAligned =
456+ newArrayWith (\s a -> liftIO $ Unboxed.pinnedNewAlignedBytes s a)
460457
461458{-# INLINE newAs #-}
462459newAs :: (MonadIO m, Unbox a) => PinnedState -> Int -> m (MutArray a)
@@ -471,9 +468,9 @@ newAs ps =
471468-- the array is uninitialized and the allocation is aligned as per the 'Unboxed'
472469-- instance of the type.
473470--
474−{-# INLINE newPinned #-}
475−newPinned :: forall m a. (MonadIO m, Unbox a) => Int -> m (MutArray a)
476−newPinned = newAs Pinned
471+{-# INLINE pinnedNew #-}
472+pinnedNew :: forall m a. (MonadIO m, Unbox a) => Int -> m (MutArray a)
473+pinnedNew = newAs Pinned
477474
478475-- | Allocates an empty unpinned array that can hold 'count' items. The memory
479476-- of the array is uninitialized.
@@ -482,21 +479,6 @@ newPinned = newAs Pinned
482479new :: (MonadIO m, Unbox a) => Int -> m (MutArray a)
483480new = newAs Unpinned
484481
485−-- XXX This should create a full length uninitialzed array so that the pointer
486−-- can be used.
487−
488−-- | Allocate a pinned MutArray of the given size and run an IO action passing
489−-- the array start pointer.
490−--
491−-- /Internal/
492−{-# INLINE withNewArrayUnsafePinned #-}
493−withNewArrayUnsafePinned ::
494− (MonadIO m, Unbox a) => Int -> (Ptr a -> m ()) -> m (MutArray a)
495−withNewArrayUnsafePinned count f = do
496− arr <- newPinned count
497− asPtrUnsafe arr
498− $ \p -> f p >> return arr
499−
500482-------------------------------------------------------------------------------
501483-- Random writes
502484-------------------------------------------------------------------------------
@@ -755,7 +737,7 @@ reallocExplicit elemSize newCapacityInBytes MutArray{..} = do
755737 let newCapMaxInBytes = roundUpLargeArray newCapacityInBytes
756738 contents <-
757739 if Unboxed.isPinned arrContents
758− then Unboxed.newPinnedBytes newCapMaxInBytes
740+ then Unboxed.pinnedNewBytes newCapMaxInBytes
759741 else Unboxed.newUnpinnedBytes newCapMaxInBytes
760742 let !(MutableByteArray mbarrFrom#) = arrContents
761743 !(MutableByteArray mbarrTo#) = contents
@@ -1864,15 +1846,15 @@ writeRevN = writeRevNWith new
18641846-- | @pinnedWriteNAligned align n@ folds a maximum of @n@ elements from the
18651847-- input stream to a 'MutArray' aligned to the given size.
18661848--
1867−-- >>> pinnedWriteNAligned align = MutArray.writeNWith (MutArray.newAlignedPinned align)
1868−-- >>> pinnedWriteNAligned align n = MutArray.writeAppendN n (MutArray.newAlignedPinned align n)
1849+-- >>> pinnedWriteNAligned align = MutArray.writeNWith (MutArray.pinnedNewAligned align)
1850+-- >>> pinnedWriteNAligned align n = MutArray.writeAppendN n (MutArray.pinnedNewAligned align n)
18691851--
18701852-- /Pre-release/
18711853--
18721854{-# INLINE_NORMAL pinnedWriteNAligned #-}
18731855pinnedWriteNAligned :: forall m a. (MonadIO m, Unbox a)
18741856 => Int -> Int -> Fold m a (MutArray a)
1875−pinnedWriteNAligned align = writeNWith (newAlignedPinned align)
1857+pinnedWriteNAligned align = writeNWith (pinnedNewAligned align)
18761858
18771859-- XXX Buffer to a list instead?
18781860--