Skip to content

Commit

Permalink
Make splitAt and splitAtWord (internal function) strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysxia authored and Bodigrim committed Mar 17, 2024
1 parent 240682e commit a1f5366
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Data/Text/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a1f5366

Please sign in to comment.