From 558f8bc9d31725dfaa946bff4aee2db0436c56b5 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 7 Jun 2010 22:49:02 +0000 Subject: In BigInt::bits, cache sig_words() result instead of calling twice --- src/math/bigint/bigint.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/math') diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp index 09ac2a75d..1f3255175 100644 --- a/src/math/bigint/bigint.cpp +++ b/src/math/bigint/bigint.cpp @@ -249,10 +249,12 @@ u32bit BigInt::bytes() const */ u32bit BigInt::bits() const { - if(sig_words() == 0) + const u32bit words = sig_words(); + + if(words == 0) return 0; - u32bit full_words = sig_words() - 1, top_bits = MP_WORD_BITS; + u32bit full_words = words - 1, top_bits = MP_WORD_BITS; word top_word = word_at(full_words), mask = MP_WORD_TOP_BIT; while(top_bits && ((top_word & mask) == 0)) -- cgit v1.2.3