@@ -185,7 +185,6 @@ import Data.Data (mkNoRepType)
185import Data.Data (mkNorepType)
185import Data.Data (mkNorepType)
187import Control.Monad (foldM)
187import Control.Monad (foldM)
188−import Control.Monad.ST (ST)
189import qualified Data.Text.Array as A
188import qualified Data.Text.Array as A
190import qualified Data.List as L
189import qualified Data.List as L
191import Data.Monoid (Monoid(..))
190import Data.Monoid (Monoid(..))
@@ -297,8 +296,8 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
297 len = len1+len2
296 len = len1+len2
299 arr <- A.unsafeNew len
298 arr <- A.unsafeNew len
300− copy arr 0 arr1 off1 len1
299+ A.partialCopyI arr 0 arr1 off1 len1
301− copy arr len1 arr2 off2 (len1+len2)
300+ A.partialCopyI arr len1 arr2 off2 (len1+len2)
302 return arr
301 return arr
303{-# INLINE append #-}
302{-# INLINE append #-}
@@ -309,14 +308,6 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
309 unstream (S.append (stream t1) (stream t2)) = append t1 t2
308 unstream (S.append (stream t1) (stream t2)) = append t1 t2
312−copy :: forall s. A.MArray s -> Int -> A.Array -> Int -> Int
314−copy dest i0 src j0 top = go i0 j0
316− go i j | i >= top = return ()
317− | otherwise = do A.unsafeWrite dest i (src `A.unsafeIndex` j)
320-- | /O(1)/ Returns the first character of a 'Text', which must be
311-- | /O(1)/ Returns the first character of a 'Text', which must be
321-- non-empty. Subject to fusion.
312-- non-empty. Subject to fusion.
322head :: Text -> Char
313head :: Text -> Char
@@ -611,7 +602,7 @@ concat ts = Text (A.run go) 0 len
611 len = L.sum (L.map (\(Text _ _ l) -> l) ts)
602 len = L.sum (L.map (\(Text _ _ l) -> l) ts)
613 arr <- A.unsafeNew len
604 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
615 foldM step 0 ts >> return arr
606 foldM step 0 ts >> return arr
616{-# INLINE concat #-}
607{-# INLINE concat #-}
@@ -721,7 +712,7 @@ replicate n t@(Text a o l)
721 arr <- A.unsafeNew len
712 arr <- A.unsafeNew len
722 let loop !d !i | i >= n = return arr
713 let loop !d !i | i >= n = return arr
723 | otherwise = let m = d + l
714 | 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)
726{-# INLINE [1] replicate #-}
717{-# INLINE [1] replicate #-}