From fe93ba14c1eed3e0fc4a34966e3046440d43ab10 Mon Sep 17 00:00:00 2001 From: Joshua Batty Date: Wed, 17 Jan 2024 15:08:24 +1100 Subject: [PATCH] wrap parse_module_cache in an Arc --- sway-core/src/query_engine/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sway-core/src/query_engine/mod.rs b/sway-core/src/query_engine/mod.rs index d7a417c6d7b..b82ae516996 100644 --- a/sway-core/src/query_engine/mod.rs +++ b/sway-core/src/query_engine/mod.rs @@ -47,14 +47,14 @@ pub type ProgramsCacheMap = HashMap; #[derive(Debug, Default)] pub struct QueryEngine { - parse_module_cache: RwLock, + parse_module_cache: Arc>, programs_cache: Arc>, } impl Clone for QueryEngine { fn clone(&self) -> Self { Self { - parse_module_cache: RwLock::new(self.parse_module_cache.read().unwrap().clone()), + parse_module_cache: self.parse_module_cache.clone(), programs_cache: self.programs_cache.clone(), } } @@ -67,11 +67,10 @@ impl QueryEngine { } pub fn insert_parse_module_cache_entry(&self, entry: ModuleCacheEntry) { - let mut cache = self.parse_module_cache.write().unwrap(); let path = entry.path.clone(); let include_tests = entry.include_tests; - let key = ModuleCacheKey::new(path, include_tests); + let mut cache = self.parse_module_cache.write().unwrap(); cache.insert(key, entry); }