diff options
author | lloyd <[email protected]> | 2010-06-07 22:49:02 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-06-07 22:49:02 +0000 |
commit | 558f8bc9d31725dfaa946bff4aee2db0436c56b5 (patch) | |
tree | 9fe274c172017f6d2730a2fceeff9266821fc655 /src/math/bigint | |
parent | 2429ac85c1d955e637ad014a1de5fd8e396f7ae5 (diff) |
In BigInt::bits, cache sig_words() result instead of calling twice
Diffstat (limited to 'src/math/bigint')
-rw-r--r-- | src/math/bigint/bigint.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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)) |