on master help sign in
Replace copy with partialCopyM

--HG-- extra : convert_revision : d4c9b8c400f8875b405096f10d5ce0222a9950e0

commit00722f16695058c9994a3603301d191210fe82f6 authorBryan O'Sullivan <bos@serpentine.com> dateSun 29 Aug 2010, 05:49 (16 years ago) parent216c52c
3 files changed+3−22
Data/Text/Array.hs−20 Data/Text/Fusion.hs+2−1 Data/Text/Lazy/Fusion.hs+1−1
Data/Text/Array.hs−20
@@ -30,7 +30,6 @@ module Data.Text.Array
3030 , MArray
3131
3232 -- * Functions
33− , copy
3433 , partialCopyM
3534 , partialCopyI
3635 , empty
@@ -205,25 +204,6 @@ wordFactor = SIZEOF_HSWORD `shiftR` 1
205204wordAligned :: Int -> Bool
206205wordAligned i = i .&. (wordFactor - 1) == 0
207206
208−-- | Copy an array in its entirety. The destination array must be at
209−-- least as big as the source.
210−copy :: MArray s -- ^ source array
211− -> MArray s -- ^ destination array
212− -> ST s ()
213−copy dest@(MArray _ dlen) src@(MArray _ slen)
214− | dlen >= slen = fast_loop 0
215− | otherwise = fail "Data.Text.Array.copy: array too small"
216− where
217− nwds = slen `div` wordFactor
218− fast_loop !i
219− | i >= nwds = copy_loop (i * wordFactor)
220− | otherwise = do unsafeReadWord src i >>= unsafeWriteWord dest i
221− fast_loop (i+1)
222− copy_loop !i
223− | i >= slen = return ()
224− | otherwise = do unsafeRead src i >>= unsafeWrite dest i
225− copy_loop (i+1)
226−
227207-- | Copy some elements of a mutable array.
228208partialCopyM :: MArray s -- ^ Destination
229209 -> Int -- ^ Destination offset
Data/Text/Fusion.hs+2−1
@@ -105,7 +105,8 @@ unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
105105 | j >= top -> {-# SCC "unstream/resize" #-} do
106106 let top' = (top + 1) `shiftL` 1
107107 arr' <- A.unsafeNew top'
108− A.copy arr' arr >> outer arr' top' s i
108+ A.partialCopyM arr' 0 arr 0 top
109+ outer arr' top' s i
109110 | otherwise -> do d <- unsafeWrite arr i x
110111 loop s' (i+d)
111112 where j | ord x < 0x10000 = i
Data/Text/Lazy/Fusion.hs+1−1
@@ -67,7 +67,7 @@ unstreamChunks chunkSize (Stream next s0 len0)
6767 | i + 1 >= len = do
6868 let newLen = min (len `shiftL` 1) chunkSize
6969 marr' <- A.unsafeNew newLen
70− A.copy marr' marr
70+ A.partialCopyM marr' 0 marr 0 len
7171 inner marr' newLen s i
7272 | otherwise =
7373 case next s of