bigint::monty: simplify work space allocation

This commit is contained in:
Josh Stone 2017-10-22 15:28:59 -07:00
parent aea5f85216
commit 4d35815426
1 changed files with 1 additions and 4 deletions

View File

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