factor: Avoid moving data around in main factoring loop
Instead, the same `Factors` object is passed around through the execution.
~10% faster.
@@ -14,8 +14,7 @@ use crate::Factors;
include!(concat!(env!("OUT_DIR"), "/prime_table.rs"));
-pub(crate) fn factor(mut num: u64) -> (Factors, u64) {
- let mut factors = Factors::one();
+pub(crate) fn factor(mut num: u64, mut factors: Factors) -> (Factors, u64) {
for &(prime, inv, ceil) in P_INVS_U64 {
if num == 1 {
break;
