bigint::monty: simplify work space allocation
This commit is contained in:
parent
aea5f85216
commit
4d35815426
|
@ -1,4 +1,3 @@
|
||||||
use std::iter::repeat;
|
|
||||||
use integer::Integer;
|
use integer::Integer;
|
||||||
use traits::{Zero, One};
|
use traits::{Zero, One};
|
||||||
|
|
||||||
|
@ -62,11 +61,9 @@ fn monty_redc(a: BigUint, mr: &MontyReducer) -> BigUint {
|
||||||
let mut c = a.data;
|
let mut c = a.data;
|
||||||
let n = &mr.n;
|
let n = &mr.n;
|
||||||
let n_size = n.len();
|
let n_size = n.len();
|
||||||
let old_size = c.len();
|
|
||||||
|
|
||||||
// Allocate sufficient work space
|
// Allocate sufficient work space
|
||||||
c.reserve(2*n_size+2-old_size);
|
c.resize(2 * n_size + 2, 0);
|
||||||
c.extend(repeat(0).take(2*n_size+2-old_size));
|
|
||||||
|
|
||||||
// β is the size of a word, in this case 32 bits. So "a mod β" is
|
// β is the size of a word, in this case 32 bits. So "a mod β" is
|
||||||
// equivalent to masking a to 32 bits.
|
// equivalent to masking a to 32 bits.
|
||||||
|
|
Loading…
Reference in New Issue