Skip to content

Commit 4d35815

Browse files
committed
bigint::monty: simplify work space allocation
1 parent aea5f85 commit 4d35815

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

bigint/src/monty.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::iter::repeat;
21
use integer::Integer;
32
use traits::{Zero, One};
43

@@ -62,11 +61,9 @@ fn monty_redc(a: BigUint, mr: &MontyReducer) -> BigUint {
6261
let mut c = a.data;
6362
let n = &mr.n;
6463
let n_size = n.len();
65-
let old_size = c.len();
6664

6765
// Allocate sufficient work space
68-
c.reserve(2*n_size+2-old_size);
69-
c.extend(repeat(0).take(2*n_size+2-old_size));
66+
c.resize(2 * n_size + 2, 0);
7067

7168
// β is the size of a word, in this case 32 bits. So "a mod β" is
7269
// equivalent to masking a to 32 bits.

0 commit comments

Comments
 (0)