Do not cache "one-hit wonders"

This commit is contained in:
Stephen Chung
2022-09-12 19:47:29 +08:00
parent c1ae9e0405
commit 44219c732c
5 changed files with 84 additions and 29 deletions

View File

@@ -234,7 +234,7 @@ impl Engine {
) -> bool {
let cache = caches.fn_resolution_cache_mut();
if let Some(result) = cache.get(&hash_script).map(Option::is_some) {
if let Some(result) = cache.map.get(&hash_script).map(Option::is_some) {
return result;
}
@@ -251,7 +251,11 @@ impl Engine {
|| self.global_sub_modules.values().any(|m| m.contains_qualified_fn(hash_script));
if !result {
cache.insert(hash_script, None);
if cache.filter.is_absent(hash_script) {
cache.filter.mark(hash_script);
} else {
cache.map.insert(hash_script, None);
}
}
result