@@ -1004,14 +1004,16 @@ take :: Int -> Text -> Text
1004take n t@(Text arr off len)
1004take n t@(Text arr off len)
1005 | n <= 0 = empty
1005 | n <= 0 = empty
1006 | n >= len = t
1006 | n >= len = t
1007− | otherwise = Text arr off (loop 0 0)
1007+ | otherwise = text arr off (iterN n t)
1010− | i >= len || cnt >= n = i
1011− | otherwise = loop (i+d) (cnt+1)
1012− where d = iter_ t i
1013{-# INLINE [1] take #-}
1008{-# INLINE [1] take #-}
1010+iterN :: Int -> Text -> Int
1011+iterN n t@(Text _arr _off len) = loop 0 0
1013+ | i >= len || cnt >= n = i
1014+ | otherwise = loop (i+d) (cnt+1)
1015+ where d = iter_ t i
1015{-# RULES
1017{-# RULES
1016"TEXT take -> fused" [~1] forall n t.
1018"TEXT take -> fused" [~1] forall n t.
1017 take n t = unstream (S.take n (stream t))
1019 take n t = unstream (S.take n (stream t))