aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint/big_ops2.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-08-21 09:26:15 -0400
committerJack Lloyd <[email protected]>2019-08-22 10:07:16 -0400
commit6adfc07738df32dc38d1b4c19e51ac3f0e21e145 (patch)
tree09bbb4c340cb2504e9e293bb8a9005595e0eda79 /src/lib/math/bigint/big_ops2.cpp
parentf4f8dc439252589263bb20221d5b865fa60b4343 (diff)
Small BigInt optimizations
Based on profiling RSA key generation
Diffstat (limited to 'src/lib/math/bigint/big_ops2.cpp')
-rw-r--r--src/lib/math/bigint/big_ops2.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp
index e758089cd..78c868a5d 100644
--- a/src/lib/math/bigint/big_ops2.cpp
+++ b/src/lib/math/bigint/big_ops2.cpp
@@ -208,8 +208,8 @@ BigInt& BigInt::mul(const BigInt& y, secure_vector<word>& ws)
}
else if(y_sw == 1 && x_sw)
{
- grow_to(x_sw + 1);
- bigint_linmul2(mutable_data(), x_sw, y.word_at(0));
+ word carry = bigint_linmul2(mutable_data(), x_sw, y.word_at(0));
+ set_word_at(x_sw, carry);
}
else
{
@@ -253,11 +253,8 @@ BigInt& BigInt::operator*=(word y)
set_sign(Positive);
}
- const size_t x_sw = sig_words();
-
- if(size() < x_sw + 1)
- grow_to(x_sw + 1);
- bigint_linmul2(mutable_data(), x_sw, y);
+ const word carry = bigint_linmul2(mutable_data(), size(), y);
+ set_word_at(size(), carry);
return (*this);
}