Simplify code by merging Engine::global_namespace with Engine::global_modules.

This commit is contained in:
Stephen Chung
2021-08-30 10:09:28 +08:00
parent 6f3de4c803
commit 6faa6358f0
4 changed files with 23 additions and 27 deletions

View File

@@ -198,12 +198,6 @@ impl Engine {
source: m.id_raw().cloned(),
})
})
.or_else(|| {
self.global_namespace
.get_fn(hash)
.cloned()
.map(|func| FnResolutionCacheEntry { func, source: None })
})
.or_else(|| {
self.global_modules.iter().find_map(|m| {
m.get_fn(hash).cloned().map(|func| FnResolutionCacheEntry {
@@ -619,8 +613,6 @@ impl Engine {
// First check script-defined functions
let result = lib.iter().any(|&m| m.contains_fn(hash_script))
// Then check registered functions
|| self.global_namespace.contains_fn(hash_script)
// Then check packages
|| self.global_modules.iter().any(|m| m.contains_fn(hash_script))
// Then check imported modules