Commit 6a728c3c authored by Bodigrim's avatar Bodigrim
Browse files

Bring type of reverseIter in line with iter

parent 1db73d54
......@@ -1163,7 +1163,7 @@ takeWhileEnd p t@(Text arr off len) = loop (len-1) len
where loop !i !l | l <= 0 = t
| p c = loop (i+d) (l+d)
| otherwise = text arr (off+l) (len-l)
where (c,d) = reverseIter t i
where Iter c d = reverseIter t i
{-# INLINE [1] takeWhileEnd #-}
-- | /O(n)/ 'dropWhile' @p@ @t@ returns the suffix remaining after
......@@ -1189,7 +1189,7 @@ dropWhileEnd p t@(Text arr off len) = loop (len-1) len
where loop !i !l | l <= 0 = empty
| p c = loop (i+d) (l+d)
| otherwise = Text arr off l
where (c,d) = reverseIter t i
where Iter c d = reverseIter t i
{-# INLINE [1] dropWhileEnd #-}
-- | /O(n)/ 'dropAround' @p@ @t@ returns the substring remaining after
......
......@@ -89,10 +89,10 @@ iter_ (Text arr off _len) i | m < 0xD800 || m > 0xDBFF = 1
-- | /O(1)/ Iterate one step backwards through a UTF-16 array,
-- returning the current character and the delta to add (i.e. a
-- negative number) to give the next offset to iterate at.
reverseIter :: Text -> Int -> (Char,Int)
reverseIter :: Text -> Int -> Iter
reverseIter (Text arr off _len) i
| m < 0xDC00 || m > 0xDFFF = (unsafeChr m, -1)
| otherwise = (chr2 n m, -2)
| m < 0xDC00 || m > 0xDFFF = Iter (unsafeChr m) (-1)
| otherwise = Iter (chr2 n m) (-2)
where m = A.unsafeIndex arr j
n = A.unsafeIndex arr k
j = off + i
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment