File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1306,12 +1306,14 @@ splitAt = loop
13061306 loop :: Int64 -> Text -> (Text , Text )
13071307 loop ! _ Empty = (empty, empty)
13081308 loop n t | n <= 0 = (empty, t)
1309- loop n (Chunk t ts)
1310- | n < len = let (t',t'') = T. splitAt (int64ToInt n) t
1311- in (Chunk t' Empty , Chunk t'' ts)
1312- | otherwise = let (ts',ts'') = loop (n - len) ts
1309+ loop n (Chunk t@ (T. Text arr off len) ts)
1310+ | m > 0 , m >= len = (Chunk t Empty , ts)
1311+ | m > 0 = let t' = T. Text arr off m
1312+ t'' = T. Text arr (off+ m) (len- m)
1313+ in (Chunk t' Empty , Chunk t'' ts)
1314+ | otherwise = let (ts', ts'') = loop (n + intToInt64 m) ts
13131315 in (Chunk t ts', ts'')
1314- where len = intToInt64 ( T. length t)
1316+ where m = T. measureOff (int64ToInt n) t
13151317
13161318-- | /O(n)/ 'splitAtWord' @n t@ returns a strict pair whose first
13171319-- element is a prefix of @t@ whose chunks contain @n@ 'Word8'
You can’t perform that action at this time.
0 commit comments