From 1ccc058794381d7d7c2ff704786009019489001d Mon Sep 17 00:00:00 2001 From: Xavier Leroy GALLIUM Date: Tue, 25 Nov 2014 19:29:32 +0100 Subject: Use Bitstring.is_zeroes_bitstring from bitstring 2.0.4. The original code is less efficient and not tail recursive. --- checklink/Bitstring_utils.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/checklink/Bitstring_utils.ml b/checklink/Bitstring_utils.ml index 2253b63f..3218f898 100644 --- a/checklink/Bitstring_utils.ml +++ b/checklink/Bitstring_utils.ml @@ -9,6 +9,13 @@ type bitstring = Bitstring.bitstring bitstring may be longer. @param size number of bits to check *) + +let is_zeros (bs: bitstring) (size: int): bool = + Bitstring.bitstring_length bs >= size + && Bitstring.is_zeroes_bitstring (Bitstring.subbitstring bs 0 size) + +(* + let rec is_zeros (bs: bitstring) (size: int): bool = size = 0 || if size >= 64 @@ -23,3 +30,4 @@ let rec is_zeros (bs: bitstring) (size: int): bool = | { 0L : size : int } -> true | { _ } -> false ) +*) -- cgit