remove the need to have same length arguments in bytesEq. bail early in case strings have different size.

This commit is contained in:
Vincent Hanquez 2012-05-14 06:32:47 +01:00
parent 9b32e6d5f4
commit d0481f76a3

View file

@ -59,6 +59,8 @@ False &&! False = False
-- | verify that 2 bytestrings are equals.
-- it's a non lazy version, that will compare every bytes.
-- arguments need to be of same length
-- arguments with different length will bail out early
bytesEq :: Bytes -> Bytes -> Bool
bytesEq b1 = and' . B.zipWith (==) b1
bytesEq b1 b2
| B.length b1 /= B.length b2 = False
| otherwise = and' $ B.zipWith (==) b1 b2