From 25a41d48dc7367d9042661562380664dbd606e2e Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 25 Mar 2013 15:41:52 -0700 Subject: [PATCH] speedup bit_vector::num_words() Proof of equivalence w.r.t. previous code: http://rise4fun.com/Z3/aiLV Signed-off-by: Nuno Lopes --- src/util/bit_vector.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/bit_vector.h b/src/util/bit_vector.h index 2e7becee7..1d6083717 100644 --- a/src/util/bit_vector.h +++ b/src/util/bit_vector.h @@ -37,7 +37,8 @@ class bit_vector { } static unsigned num_words(unsigned num_bits) { - return (num_bits % 32) == 0 ? (num_bits / 32) : ((num_bits / 32) + 1); + // return (num_bits % 32) == 0 ? (num_bits / 32) : ((num_bits / 32) + 1); + return (num_bits + 31) / 32; } void expand_to(unsigned new_capacity);