diff options
author | Jack Lloyd <[email protected]> | 2018-03-25 15:55:47 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-25 15:55:47 -0400 |
commit | a2b2f94d3190bee6e296718cd1d39f6425b77ab0 (patch) | |
tree | f7c746894ea6c48b90e92696e1d1e63bf148e156 /src/lib | |
parent | 04729be983f3090595f92c2d4752081487ea7c4d (diff) |
In Barrett avoid creating an unnecessary temp
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/math/numbertheory/reducer.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/math/numbertheory/reducer.cpp b/src/lib/math/numbertheory/reducer.cpp index e9db7753b..9dbcfb9a3 100644 --- a/src/lib/math/numbertheory/reducer.cpp +++ b/src/lib/math/numbertheory/reducer.cpp @@ -62,10 +62,10 @@ BigInt Modular_Reducer::reduce(const BigInt& x) const t1.reduce_below(m_modulus, ws); - if(x.is_positive()) - return t1; - else - return (m_modulus - t1); + if(x.is_negative()) + t1.rev_sub(m_modulus.data(), m_modulus.size(), ws); + + return t1; } else { |