Only make a single cache key (minor optimization)
This commit is contained in:
@@ -60,11 +60,12 @@ fn create_permutations_recurse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_permutations(set: HashSet<Op>, len: usize) -> HashSet<Vec<Op>> {
|
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;
|
return cached_value;
|
||||||
}
|
}
|
||||||
let mut permutations = HashSet::new();
|
let mut permutations = HashSet::new();
|
||||||
create_permutations_recurse(&set, len, &mut permutations, vec![]);
|
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
|
permutations
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user