Do not preallocate the vec to the known size so we are fair and do what other tests are doing
parent
440680629c
commit
e989f1fda3
|
@ -10,7 +10,7 @@ fn get_primes7(count: u32) -> Vec<u32> {
|
||||||
return vec![2];
|
return vec![2];
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut s = Vec::with_capacity(count as usize / 2);
|
let mut s = Vec::new();
|
||||||
let mut i = 3;
|
let mut i = 3;
|
||||||
while i < count+1 {
|
while i < count+1 {
|
||||||
s.push(i);
|
s.push(i);
|
||||||
|
@ -36,11 +36,6 @@ fn get_primes7(count: u32) -> Vec<u32> {
|
||||||
m = 2*i+3;
|
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();
|
let mut res = Vec::new();
|
||||||
res.push(2);
|
res.push(2);
|
||||||
res.extend(s.into_iter().filter(|x| *x != 0));
|
res.extend(s.into_iter().filter(|x| *x != 0));
|
||||||
|
@ -65,4 +60,3 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue