aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-15 22:58:34 +0000
committerlloyd <[email protected]>2008-09-15 22:58:34 +0000
commit9f389e512c00d0c45731d93e2977c14c408a4356 (patch)
tree52ad6c6f2e660495cd56b24552a59c0f1cac472f /src
parent72fe4ae840e6a8f9d101b11ffd6404f42c0469bf (diff)
Remove the cache for BigInt::sig_words. I'm baffled how it is it works
on x86, x86-64, and m68k and not other platforms. Something about the memory model I'm hitting? Valgrind shows nothing. Rather than struggle with it further, for minimal gain, I'm reverting. If someone ever does figure it out, this will be easy to reapply.
Diffstat (limited to 'src')
-rw-r--r--src/bigint.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp
index 1ba53cb9a..e3c7931e6 100644
--- a/src/bigint.cpp
+++ b/src/bigint.cpp
@@ -23,9 +23,9 @@ BigInt::BigInt(u64bit n)
const u32bit limbs_needed = sizeof(u64bit) / sizeof(word);
- get_reg().create(4*limbs_needed);
+ reg.create(4*limbs_needed);
for(u32bit j = 0; j != limbs_needed; ++j)
- rep[j] = ((n >> (j*MP_WORD_BITS)) & MP_WORD_MASK);
+ reg[j] = ((n >> (j*MP_WORD_BITS)) & MP_WORD_MASK);
}
/*************************************************
@@ -33,7 +33,7 @@ BigInt::BigInt(u64bit n)
*************************************************/
BigInt::BigInt(Sign s, u32bit size)
{
- get_reg().create(round_up(size, 8));
+ reg.create(round_up(size, 8));
signedness = s;
}
@@ -46,13 +46,13 @@ BigInt::BigInt(const BigInt& b)
if(b_words)
{
- get_reg().create(round_up(b_words, 8));
- get_reg().copy(b.data(), b_words);
+ reg.create(round_up(b_words, 8));
+ reg.copy(b.data(), b_words);
set_sign(b.sign());
}
else
{
- get_reg().create(2);
+ reg.create(2);
set_sign(Positive);
}
}
@@ -103,7 +103,7 @@ BigInt::BigInt(RandomNumberGenerator& rng, u32bit bits)
*************************************************/
void BigInt::swap(BigInt& other)
{
- rep.swap(other.rep);
+ reg.swap(other.reg);
std::swap(signedness, other.signedness);
}
@@ -112,7 +112,7 @@ void BigInt::swap(BigInt& other)
*************************************************/
void BigInt::grow_reg(u32bit n)
{
- get_reg().grow_to(round_up(size() + n, 8));
+ reg.grow_to(round_up(size() + n, 8));
}
/*************************************************
@@ -121,7 +121,7 @@ void BigInt::grow_reg(u32bit n)
void BigInt::grow_to(u32bit n)
{
if(n > size())
- get_reg().grow_to(round_up(n, 8));
+ reg.grow_to(round_up(n, 8));
}
/*************************************************
@@ -165,7 +165,7 @@ byte BigInt::byte_at(u32bit n) const
if(word_num >= size())
return 0;
else
- return get_byte(WORD_BYTES - byte_num - 1, rep[word_num]);
+ return get_byte(WORD_BYTES - byte_num - 1, reg[word_num]);
}
/*************************************************
@@ -202,7 +202,7 @@ void BigInt::set_bit(u32bit n)
const u32bit which = n / MP_WORD_BITS;
const word mask = static_cast<word>(1) << (n % MP_WORD_BITS);
if(which >= size()) grow_to(which + 1);
- rep[which] |= mask;
+ reg[which] |= mask;
}
/*************************************************
@@ -213,7 +213,7 @@ void BigInt::clear_bit(u32bit n)
const u32bit which = n / MP_WORD_BITS;
const word mask = static_cast<word>(1) << (n % MP_WORD_BITS);
if(which < size())
- rep[which] &= ~mask;
+ reg[which] &= ~mask;
}
/*************************************************
@@ -229,9 +229,9 @@ void BigInt::mask_bits(u32bit n)
if(top_word < size())
for(u32bit j = top_word + 1; j != size(); ++j)
- rep[j] = 0;
+ reg[j] = 0;
- rep[top_word] &= mask;
+ reg[top_word] &= mask;
}
/*************************************************
@@ -344,8 +344,6 @@ void BigInt::binary_decode(const byte buf[], u32bit length)
{
const u32bit WORD_BYTES = sizeof(word);
- SecureVector<word>& reg = get_reg();
-
reg.create(round_up((length / WORD_BYTES) + 1, 8));
for(u32bit j = 0; j != length / WORD_BYTES; ++j)