Skip to content

Commit

Permalink
chore: clearer code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Dec 24, 2024
1 parent f698eb2 commit e0fa1f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/host/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,8 @@ impl ModuleCache {
/// Get a module from the cache, or add it to both caches if not found
pub fn get(&self, key: CacheKey, wasm: &[u8]) -> Result<Arc<Module>, wasmer::RuntimeError> {
// Check in-memory deserialized cache for module
{
let mut deserialized_cache = self.deserialized_module_cache.write();
if let Some(module) = deserialized_cache.get_item(&key) {
return Ok(module);
}
if let Some(module) = self.get_from_deserialized_cache(key) {
return Ok(module);
}

// Check the filesystem cache for serialized module
Expand Down Expand Up @@ -314,6 +311,12 @@ impl ModuleCache {
Ok(())
}

/// Check deserialized cache for module
fn get_from_deserialized_cache(&self, key: CacheKey) -> Option<Arc<Module>> {
let mut deserialized_cache = self.deserialized_module_cache.write();
deserialized_cache.get_item(&key)
}

/// Add module to deserialized cache
fn add_to_deserialized_cache(&self, key: CacheKey, module: Arc<Module>) {
let mut deserialized_cache = self.deserialized_module_cache.write();
Expand Down

0 comments on commit e0fa1f3

Please sign in to comment.