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