on master help sign in
Add and fix some comments
e4c5cb9Harendra Kumar
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+11−7
@@ -703,13 +703,12 @@ arrayChunkBytes = 1024
703-------------------------------------------------------------------------------
703-------------------------------------------------------------------------------
704
704
705-- XXX We can possibly use a smallMutableByteArray to hold the start, end,
705-- XXX We can possibly use a smallMutableByteArray to hold the start, end,
706−-- bound pointers. Or we can use the first 16 bytes of the allocation to store
707−-- the end, bound pointers. Using fully mutable handle will ensure that we do
706+-- bound pointers. Using fully mutable handle will ensure that we do not have
708−-- not have multiple references to the same array of different lengths lying
707+-- multiple references to the same array of different lengths lying around and
709−-- around and potentially misused. In that case "snoc" need not return a new
708+-- potentially misused. In that case "snoc" need not return a new array (snoc
710−-- array (snoc :: Array a -> a -> m ()), it will just modify the old reference.
709+-- :: Array a -> a -> m ()), it will just modify the old reference. The array
711−-- The array length will be mutable. This means the length function would also
710+-- length will be mutable. This means the length function would also be
712−-- be monadic. Mutable arrays would behave more like files that grow in that
711+-- monadic. Mutable arrays would behave more like files that grow in that
713-- case.
712-- case.
714
713
715-- | Snoc using a 'Ptr'. Low level reusable function.
714-- | Snoc using a 'Ptr'. Low level reusable function.
@@ -846,6 +845,9 @@ snoc = snocWith (* 2)
846-- Resizing
845-- Resizing
847-------------------------------------------------------------------------------
846-------------------------------------------------------------------------------
848
847
848+-- XXX See if resizing can be implemented by reading the old array as a stream
849+-- and then using writeN to the new array.
850+--
849-- | Reallocate the array to the specified size in bytes. If the size is less
851-- | Reallocate the array to the specified size in bytes. If the size is less
850-- than the original array the array gets truncated.
852-- than the original array the array gets truncated.
851{-# NOINLINE reallocAligned #-}
853{-# NOINLINE reallocAligned #-}
@@ -925,6 +927,8 @@ rightSize arr@Array{..} = do
925-- Reducing the length
927-- Reducing the length
926-------------------------------------------------------------------------------
928-------------------------------------------------------------------------------
927
929
930+-- XXX Either slice the array or stream it and write it out to a new array?
931+--
928-- | Drop the last n elements of the array to reduce the length by n. The
932-- | Drop the last n elements of the array to reduce the length by n. The
929-- capacity is reallocated using the user supplied function.
933-- capacity is reallocated using the user supplied function.
930--
934--