diff --git a/lib/src/chunking.rs b/lib/src/chunking.rs index 26221588..fb487e32 100644 --- a/lib/src/chunking.rs +++ b/lib/src/chunking.rs @@ -490,38 +490,27 @@ fn get_partitions_with_threshold( let freq = pkg.meta.change_frequency as f64; //low frequency, high size + let bucket; if (freq <= med_freq_low_limit) && (size >= med_size_high_limit) { - partitions - .entry("lf_hs".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "lf_hs"; } //medium frequency, high size else if (freq < med_freq_high_limit) && (freq > med_freq_low_limit) && (size >= med_size_high_limit) { - partitions - .entry("mf_hs".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "mf_hs"; } //high frequency, high size else if (freq >= med_freq_high_limit) && (size >= med_size_high_limit) { - partitions - .entry("hf_hs".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "hf_hs"; } //low frequency, medium size else if (freq <= med_freq_low_limit) && (size < med_size_high_limit) && (size > med_size_low_limit) { - partitions - .entry("lf_ms".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "lf_fs"; } //medium frequency, medium size else if (freq < med_freq_high_limit) @@ -529,45 +518,37 @@ fn get_partitions_with_threshold( && (size < med_size_high_limit) && (size > med_size_low_limit) { - partitions - .entry("mf_ms".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "mf_ms"; } //high frequency, medium size else if (freq >= med_freq_high_limit) && (size < med_size_high_limit) && (size > med_size_low_limit) { - partitions - .entry("hf_ms".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "hf_ms"; } //low frequency, low size else if (freq <= med_freq_low_limit) && (size <= med_size_low_limit) { - partitions - .entry("lf_ls".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "lf_ls"; } //medium frequency, low size else if (freq < med_freq_high_limit) && (freq > med_freq_low_limit) && (size <= med_size_low_limit) { - partitions - .entry("mf_ls".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "mf_ls"; } //high frequency, low size else if (freq >= med_freq_high_limit) && (size <= med_size_low_limit) { - partitions - .entry("hf_ls".to_string()) - .and_modify(|bin| bin.push(pkg)) - .or_insert_with(|| vec![pkg]); + bucket = "hf_ls"; + } else { + unreachable!() } + + partitions + .entry(bucket.to_string()) + .and_modify(|bin| bin.push(pkg)) + .or_insert_with(|| vec![pkg]); } for (name, pkgs) in &partitions {