@@ -476,7 +476,6 @@ ensure n = T.Parser $ \t pos more lose succ ->
476 Just n' -> succ t pos more (n', substring pos n' t)
476 Just n' -> succ t pos more (n', substring pos n' t)
477 -- The uncommon case is kept out-of-line to reduce code size:
477 -- The uncommon case is kept out-of-line to reduce code size:
478 Nothing -> ensureSuspended n t pos more lose succ
478 Nothing -> ensureSuspended n t pos more lose succ
479−-- Non-recursive so the bounds check can be inlined:
480{-# INLINE ensure #-}
479{-# INLINE ensure #-}
482-- | Return both the result of a parse and the portion of the input
481-- | Return both the result of a parse and the portion of the input
@@ -487,6 +486,7 @@ match p = T.Parser $ \t pos more lose succ ->
487 (substring pos (pos'-pos) t', a)
486 (substring pos (pos'-pos) t', a)
488 in runParser p t pos more lose succ'
487 in runParser p t pos more lose succ'
489+-- | Ensure that at least @n@ code points of input are available.
490lengthAtLeast :: Pos -> Int -> Buffer -> Maybe Pos
490lengthAtLeast :: Pos -> Int -> Buffer -> Maybe Pos
491lengthAtLeast pos n t = go 0 (fromPos pos)
491lengthAtLeast pos n t = go 0 (fromPos pos)
492 where go i !p
492 where go i !p