diff options
author | lloyd <[email protected]> | 2012-08-01 14:13:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-08-01 14:13:49 +0000 |
commit | 3f7b562cd6a51cd796f3cb1c0151c45f2b24e2b0 (patch) | |
tree | 30efa6741faa24512014e4c08e261e717e4860cb /src/math/bigint | |
parent | afaac2c3668f0a0fced85649651d3d2ee9101a67 (diff) |
Remove BigInt::operator[] returning a mutable word reference
Diffstat (limited to 'src/math/bigint')
-rw-r--r-- | src/math/bigint/bigint.h | 7 | ||||
-rw-r--r-- | src/math/bigint/divide.cpp | 13 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h index f026e67f1..6efe53e71 100644 --- a/src/math/bigint/bigint.h +++ b/src/math/bigint/bigint.h @@ -128,13 +128,6 @@ class BOTAN_DLL BigInt * @param i a word index * @return the word at index i */ - word& operator[](size_t i) { return m_reg[i]; } - - /** - * [] operator (array access) - * @param i a word index - * @return the word at index i - */ const word& operator[](size_t i) const { return m_reg[i]; } /** diff --git a/src/math/bigint/divide.cpp b/src/math/bigint/divide.cpp index df72ec3a1..e6d768b1c 100644 --- a/src/math/bigint/divide.cpp +++ b/src/math/bigint/divide.cpp @@ -66,6 +66,9 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r) throw Internal_Error("BigInt division word sizes"); q.grow_to(n - t + 1); + + word* q_words = q.mutable_data(); + if(n <= t) { while(r > y) { r -= y; ++q; } @@ -76,7 +79,7 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r) BigInt temp = y << (MP_WORD_BITS * (n-t)); - while(r >= temp) { r -= temp; ++q[n-t]; } + while(r >= temp) { r -= temp; q_words[n-t] += 1; } for(size_t j = n; j != t; --j) { @@ -85,19 +88,19 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r) const word y_t = y.word_at(t); if(x_j0 == y_t) - q[j-t-1] = MP_WORD_MAX; + q_words[j-t-1] = MP_WORD_MAX; else - q[j-t-1] = bigint_divop(x_j0, x_j1, y_t); + q_words[j-t-1] = bigint_divop(x_j0, x_j1, y_t); while(bigint_divcore(q[j-t-1], y_t, y.word_at(t-1), x_j0, x_j1, r.word_at(j-2))) - --q[j-t-1]; + q_words[j-t-1] -= 1; r -= (q[j-t-1] * y) << (MP_WORD_BITS * (j-t-1)); if(r.is_negative()) { r += y << (MP_WORD_BITS * (j-t-1)); - --q[j-t-1]; + q_words[j-t-1] -= 1; } } r >>= shifts; |