@@ -185,7 +185,6 @@ import Data.Data (mkNoRepType)
185185import Data.Data (mkNorepType)
186186#endif
187187import Control.Monad (foldM)
188−import Control.Monad.ST (ST)
189188import qualified Data.Text.Array as A
190189import qualified Data.List as L
191190import Data.Monoid (Monoid(..))
@@ -297,8 +296,8 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
297296 len = len1+len2
298297 x = do
299298 arr <- A.unsafeNew len
300− copy arr 0 arr1 off1 len1
301− copy arr len1 arr2 off2 (len1+len2)
299+ A.partialCopyI arr 0 arr1 off1 len1
300+ A.partialCopyI arr len1 arr2 off2 (len1+len2)
302301 return arr
303302{-# INLINE append #-}
304303
@@ -309,14 +308,6 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
309308 unstream (S.append (stream t1) (stream t2)) = append t1 t2
310309 #-}
311310
312−copy :: forall s. A.MArray s -> Int -> A.Array -> Int -> Int
313− -> ST s ()
314−copy dest i0 src j0 top = go i0 j0
315− where
316− go i j | i >= top = return ()
317− | otherwise = do A.unsafeWrite dest i (src `A.unsafeIndex` j)
318− go (i+1) (j+1)
319−
320311-- | /O(1)/ Returns the first character of a 'Text', which must be
321312-- non-empty. Subject to fusion.
322313head :: Text -> Char
@@ -611,7 +602,7 @@ concat ts = Text (A.run go) 0 len
611602 len = L.sum (L.map (\(Text _ _ l) -> l) ts)
612603 go = do
613604 arr <- A.unsafeNew len
614− let step i (Text a o l) = let j = i + l in copy arr i a o j >> return j
605+ let step i (Text a o l) = let j = i + l in A.partialCopyI arr i a o j >> return j
615606 foldM step 0 ts >> return arr
616607{-# INLINE concat #-}
617608
@@ -721,7 +712,7 @@ replicate n t@(Text a o l)
721712 arr <- A.unsafeNew len
722713 let loop !d !i | i >= n = return arr
723714 | otherwise = let m = d + l
724− in copy arr d a o m >> loop m (i+1)
715+ in A.partialCopyI arr d a o m >> loop m (i+1)
725716 loop 0 0
726717{-# INLINE [1] replicate #-}
727718