@@ -1018,6 +1018,14 @@ take n t@(Text arr off len)
1018 unstream (S.take n (stream t)) = take n t
1018 unstream (S.take n (stream t)) = take n t
1021+iterNEnd :: Int -> Text -> Int
1022+iterNEnd n t@(Text _arr _off len) = loop (len-1) n
1026+ | otherwise = loop (i+d) (m-1)
1027+ where d = reverseIter_ t i
1021-- | /O(n)/ 'drop' @n@, applied to a 'Text', returns the suffix of the
1029-- | /O(n)/ 'drop' @n@, applied to a 'Text', returns the suffix of the
1022-- 'Text' after the first @n@ characters, or the empty 'Text' if @n@
1030-- 'Text' after the first @n@ characters, or the empty 'Text' if @n@
1023-- is greater than the length of the 'Text'. Subject to fusion.
1031-- is greater than the length of the 'Text'. Subject to fusion.
@@ -1049,12 +1057,7 @@ dropEnd :: Int -> Text -> Text
1049dropEnd n t@(Text arr off len)
1057dropEnd n t@(Text arr off len)
1050 | n <= 0 = t
1058 | n <= 0 = t
1051 | n >= len = empty
1059 | n >= len = empty
1052− | otherwise = loop (len-1) n
1060+ | otherwise = text arr off (iterNEnd n t)
1055− | m <= 1 = Text arr off i
1056− | otherwise = loop (i+d) (m-1)
1057− where d = reverseIter_ t i
1059-- | /O(n)/ 'takeWhile', applied to a predicate @p@ and a 'Text',
1062-- | /O(n)/ 'takeWhile', applied to a predicate @p@ and a 'Text',
1060-- returns the longest prefix (possibly empty) of elements that
1063-- returns the longest prefix (possibly empty) of elements that