@@ -113,8 +113,12 @@ ensure' n0 i0 a0 m0 kf0 ks0 =
113113ensure :: Int -> Parser B.ByteString
114114ensure !n = T.Parser $ \i0 a0 m0 kf ks ->
115115 if B.length (unI i0) >= n
116+ -- Inline the success continuation to avoid creating a closure in
117+ -- the common case of enough data in the buffer:
116118 then inline ks i0 a0 m0 (unI i0)
119+ -- The uncommon case is kept out-of-line to reduce code size:
117120 else ensure' n i0 a0 m0 kf ks
121+-- Non-recursive so the bounds check can be inlined:
118122{-# INLINE ensure #-}
119123
120124-- | Ask for input. If we receive any, pass it to a success