@@ -946,12 +946,11 @@ take i t0 = take' i t0
946takeEnd :: Int64 -> Text -> Text
946takeEnd :: Int64 -> Text -> Text
947takeEnd n t0
947takeEnd n t0
948 | n <= 0 = empty
948 | n <= 0 = empty
949− | otherwise = fromChunks . L.reverse .
950− takeChunk n . L.reverse . toChunks $ t0
949+ | otherwise = takeChunk n empty . L.reverse . toChunks $ t0
951− where takeChunk _ [] = []
950+ where takeChunk _ acc [] = acc
952− takeChunk i (t:ts)
951+ takeChunk i acc (t:ts)
953− | i <= l = [T.takeEnd (fromIntegral i) t]
952+ | i <= l = chunk (T.takeEnd (fromIntegral i) t) acc
954− | otherwise = t : takeChunk (i-l) ts
953+ | otherwise = takeChunk (i-l) (Chunk t acc) ts
955 where l = fromIntegral (T.length t)
954 where l = fromIntegral (T.length t)
957-- | /O(n)/ 'drop' @n@, applied to a 'Text', returns the suffix of the
956-- | /O(n)/ 'drop' @n@, applied to a 'Text', returns the suffix of the