on master help sign in
isEmpty: check bs first

suggested by @kolmodin

commit39618a7ae449a12e09de6b3bdb67e9222baa3b2c authorAlexander Polakov <plhk@sdf.org> dateSun 31 Mar 2013, 18:37 (14 years ago) parentbec131c
1 file changed+3−1
Data/Binary/Bits/Get.hs+3−1
Data/Binary/Bits/Get.hs+3−1
@@ -430,7 +430,9 @@ getLazyByteString n = do
430430-- | Test whether all input has been consumed, i.e. there are no remaining
431431-- undecoded bytes.
432432isEmpty :: BitGet Bool
433−isEmpty = B $ \ (S bs o) -> B.isEmpty >>= \e -> return (S bs o, e)
433+isEmpty = B $ \ (S bs o) -> if B.null bs
434+ then B.isEmpty >>= \e -> return (S bs o, e)
435+ else return (S bs o, False)
434436
435437-- | Read a 1 bit 'Bool'.
436438bool :: Block Bool