From 4f169dd5c1db11ce60f25b829ca2d2b1ef5d8bf9 Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Thu, 14 Mar 2024 18:22:46 +0100 Subject: [PATCH] Make splitAt and splitAtWord (internal function) strict --- src/Data/Text/Lazy.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Text/Lazy.hs b/src/Data/Text/Lazy.hs index 41e6885d..b593e328 100644 --- a/src/Data/Text/Lazy.hs +++ b/src/Data/Text/Lazy.hs @@ -1239,7 +1239,7 @@ splitAt :: Int64 -> Text -> (Text, Text) splitAt = loop where loop :: Int64 -> Text -> (Text, Text) - loop _ Empty = (empty, empty) + loop !_ Empty = (empty, empty) loop n t | n <= 0 = (empty, t) loop n (Chunk t ts) | n < len = let (t',t'') = T.splitAt (int64ToInt n) t @@ -1252,7 +1252,7 @@ splitAt = loop -- element is a prefix of @t@ whose chunks contain @n@ 'Word8' -- values, and whose second is the remainder of the string. splitAtWord :: Int64 -> Text -> PairS Text Text -splitAtWord _ Empty = empty :*: empty +splitAtWord !_ Empty = empty :*: empty splitAtWord x (Chunk c@(T.Text arr off len) cs) | y >= len = let h :*: t = splitAtWord (x-intToInt64 len) cs in Chunk c h :*: t