on master help sign in
Rename partialCopy to copy
b475569Bryan O'Sullivan
Data/Text.hs+4−4
@@ -298,8 +298,8 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
298 len = len1+len2
298 len = len1+len2
299 x = do
299 x = do
300 arr <- A.unsafeNew len
300 arr <- A.unsafeNew len
301− A.partialCopyI arr 0 arr1 off1 len1
301+ A.copyI arr 0 arr1 off1 len1
302− A.partialCopyI arr len1 arr2 off2 (len1+len2)
302+ A.copyI arr len1 arr2 off2 (len1+len2)
303 return arr
303 return arr
304{-# INLINE append #-}
304{-# INLINE append #-}
305
305
@@ -660,7 +660,7 @@ concat ts = case ts' of
660 go = do
660 go = do
661 arr <- A.unsafeNew len
661 arr <- A.unsafeNew len
662 let step i (Text a o l) =
662 let step i (Text a o l) =
663− let !j = i + l in A.partialCopyI arr i a o j >> return j
663+ let !j = i + l in A.copyI arr i a o j >> return j
664 foldM step 0 ts' >> return arr
664 foldM step 0 ts' >> return arr
665
665
666-- | /O(n)/ Map a function over a 'Text' that results in a 'Text', and
666-- | /O(n)/ Map a function over a 'Text' that results in a 'Text', and
@@ -769,7 +769,7 @@ replicate n t@(Text a o l)
769 arr <- A.unsafeNew len
769 arr <- A.unsafeNew len
770 let loop !d !i | i >= n = return arr
770 let loop !d !i | i >= n = return arr
771 | otherwise = let m = d + l
771 | otherwise = let m = d + l
772− in A.partialCopyI arr d a o m >> loop m (i+1)
772+ in A.copyI arr d a o m >> loop m (i+1)
773 loop 0 0
773 loop 0 0
774{-# INLINE [1] replicate #-}
774{-# INLINE [1] replicate #-}
775
775
Data/Text/Array.hs+16−16
@@ -30,8 +30,8 @@ module Data.Text.Array
30 , MArray
30 , MArray
31
31
32 -- * Functions
32 -- * Functions
33− , partialCopyM
33+ , copyM
34− , partialCopyI
34+ , copyI
35 , empty
35 , empty
36 , run
36 , run
37 , run2
37 , run2
@@ -205,13 +205,13 @@ wordAligned :: Int -> Bool
205wordAligned i = i .&. (wordFactor - 1) == 0
205wordAligned i = i .&. (wordFactor - 1) == 0
206
206
207-- | Copy some elements of a mutable array.
207-- | Copy some elements of a mutable array.
208−partialCopyM :: MArray s -- ^ Destination
208+copyM :: MArray s -- ^ Destination
209− -> Int -- ^ Destination offset
209+ -> Int -- ^ Destination offset
210− -> MArray s -- ^ Source
210+ -> MArray s -- ^ Source
211− -> Int -- ^ Source offset
211+ -> Int -- ^ Source offset
212− -> Int -- ^ Count
212+ -> Int -- ^ Count
213− -> ST s ()
213+ -> ST s ()
214−partialCopyM dest didx src sidx count =
214+copyM dest didx src sidx count =
215#if defined(ASSERTS)
215#if defined(ASSERTS)
216 assert (sidx + count <= length src) .
216 assert (sidx + count <= length src) .
217 assert (didx + count <= length dest) $
217 assert (didx + count <= length dest) $
@@ -234,14 +234,14 @@ partialCopyM dest didx src sidx count =
234 slow_loop (i+1)
234 slow_loop (i+1)
235
235
236-- | Copy some elements of an immutable array.
236-- | Copy some elements of an immutable array.
237−partialCopyI :: MArray s -- ^ Destination
237+copyI :: MArray s -- ^ Destination
238− -> Int -- ^ Destination offset
238+ -> Int -- ^ Destination offset
239− -> Array -- ^ Source
239+ -> Array -- ^ Source
240− -> Int -- ^ Source offset
240+ -> Int -- ^ Source offset
241− -> Int -- ^ First offset in source /not/ to
241+ -> Int -- ^ First offset in source /not/ to
242 -- copy (i.e. /not/ length)
242 -- copy (i.e. /not/ length)
243− -> ST s ()
243+ -> ST s ()
244−partialCopyI dest i0 src j0 top
244+copyI dest i0 src j0 top
245 | wordAligned i0 && wordAligned j0 = fast (i0 `div` wordFactor) (j0 `div` wordFactor)
245 | wordAligned i0 && wordAligned j0 = fast (i0 `div` wordFactor) (j0 `div` wordFactor)
246 | otherwise = slow i0 j0
246 | otherwise = slow i0 j0
247 where
247 where
Data/Text/Fusion.hs+2−2
@@ -105,7 +105,7 @@ unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
105 | j >= top -> {-# SCC "unstream/resize" #-} do
105 | j >= top -> {-# SCC "unstream/resize" #-} do
106 let top' = (top + 1) `shiftL` 1
106 let top' = (top + 1) `shiftL` 1
107 arr' <- A.unsafeNew top'
107 arr' <- A.unsafeNew top'
108− A.partialCopyM arr' 0 arr 0 top
108+ A.copyM arr' 0 arr 0 top
109 outer arr' top' s i
109 outer arr' top' s i
110 | otherwise -> do d <- unsafeWrite arr i x
110 | otherwise -> do d <- unsafeWrite arr i x
111 loop s' (i+d)
111 loop s' (i+d)
@@ -138,7 +138,7 @@ reverse (Stream next s len0)
138 Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
138 Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
139 let newLen = len `shiftL` 1
139 let newLen = len `shiftL` 1
140 marr' <- A.unsafeNew newLen
140 marr' <- A.unsafeNew newLen
141− A.partialCopyM marr' (newLen-len) marr 0 len
141+ A.copyM marr' (newLen-len) marr 0 len
142 write s1 (len+i) newLen marr'
142 write s1 (len+i) newLen marr'
143 | otherwise -> write s1 i len marr
143 | otherwise -> write s1 i len marr
144 where n = ord x
144 where n = ord x
Data/Text/Lazy/Builder.hs+1−1
@@ -122,7 +122,7 @@ copyLimit = 128
122fromText :: S.Text -> Builder
122fromText :: S.Text -> Builder
123fromText t@(Text arr off l)
123fromText t@(Text arr off l)
124 | S.null t = empty
124 | S.null t = empty
125− | l <= copyLimit = writeN l $ \marr o -> A.partialCopyI marr o arr off (l+o)
125+ | l <= copyLimit = writeN l $ \marr o -> A.copyI marr o arr off (l+o)
126 | otherwise = flush `append` mapBuilder (t :)
126 | otherwise = flush `append` mapBuilder (t :)
127{-# INLINE [1] fromText #-}
127{-# INLINE [1] fromText #-}
128
128
Data/Text/Lazy/Fusion.hs+1−1
@@ -67,7 +67,7 @@ unstreamChunks chunkSize (Stream next s0 len0)
67 | i + 1 >= len = do
67 | i + 1 >= len = do
68 let newLen = min (len `shiftL` 1) chunkSize
68 let newLen = min (len `shiftL` 1) chunkSize
69 marr' <- A.unsafeNew newLen
69 marr' <- A.unsafeNew newLen
70− A.partialCopyM marr' 0 marr 0 len
70+ A.copyM marr' 0 marr 0 len
71 inner marr' newLen s i
71 inner marr' newLen s i
72 | otherwise =
72 | otherwise =
73 case next s of
73 case next s of