Only make a single cache key (minor optimization)

This commit is contained in:
2025-06-16 13:36:02 -05:00
parent a7b3d9225b
commit ec0267a455

View File

@@ -60,11 +60,12 @@ fn create_permutations_recurse(
}
pub fn create_permutations(set: HashSet<Op>, len: usize) -> HashSet<Vec<Op>> {
if let Some(cached_value) = check_operator_set_cache(&PermutationCacheKey::new(len, &set)) {
let cache_key = PermutationCacheKey::new(len, &set);
if let Some(cached_value) = check_operator_set_cache(&cache_key) {
return cached_value;
}
let mut permutations = HashSet::new();
create_permutations_recurse(&set, len, &mut permutations, vec![]);
store_operator_set_in_cache(PermutationCacheKey::new(len, &set), permutations.clone());
store_operator_set_in_cache(cache_key, permutations.clone());
permutations
}