Do not preallocate the vec to the known size so we are fair and do what other tests are doing

master
Nikolay Denev 2016-10-09 23:54:53 +02:00
parent 440680629c
commit e989f1fda3
1 changed files with 1 additions and 7 deletions

View File

@ -10,7 +10,7 @@ fn get_primes7(count: u32) -> Vec<u32> {
return vec![2];
}
let mut s = Vec::with_capacity(count as usize / 2);
let mut s = Vec::new();
let mut i = 3;
while i < count+1 {
s.push(i);
@ -36,11 +36,6 @@ fn get_primes7(count: u32) -> Vec<u32> {
m = 2*i+3;
}
//s.push(2);
//s.retain(|&x| x != 0);
//s
//let mut res = Vec::with_capacity(count as usize /2);
let mut res = Vec::new();
res.push(2);
res.extend(s.into_iter().filter(|x| *x != 0));
@ -65,4 +60,3 @@ fn main() {
}
}