Use a bloom filter.

This commit is contained in:
Stephen Chung
2022-09-08 17:49:37 +08:00
parent 1476b14831
commit 1bfedf516d
8 changed files with 217 additions and 178 deletions

View File

@@ -239,21 +239,21 @@ impl Engine {
// Check `Dynamic` parameters for functions with parameters
if allow_dynamic && max_bitmask == 0 && num_args > 0 {
let is_dynamic = lib.iter().any(|&m| m.contains_dynamic_fn(hash_base))
let is_dynamic = lib.iter().any(|&m| m.may_contain_dynamic_fn(hash_base))
|| self
.global_modules
.iter()
.any(|m| m.contains_dynamic_fn(hash_base));
.any(|m| m.may_contain_dynamic_fn(hash_base));
#[cfg(not(feature = "no_module"))]
let is_dynamic = is_dynamic
|| _global
.iter_imports_raw()
.any(|(_, m)| m.contains_dynamic_fn(hash_base))
.any(|(_, m)| m.may_contain_dynamic_fn(hash_base))
|| self
.global_sub_modules
.values()
.any(|m| m.contains_dynamic_fn(hash_base));
.any(|m| m.may_contain_dynamic_fn(hash_base));
// Set maximum bitmask when there are dynamic versions of the function
if is_dynamic {

View File

@@ -9,13 +9,9 @@ use std::{
#[cfg(feature = "no_std")]
pub type StraightHashMap<K, V> = hashbrown::HashMap<K, V, StraightHasherBuilder>;
#[cfg(feature = "no_std")]
pub type StraightHashSet<K> = hashbrown::HashSet<K, StraightHasherBuilder>;
#[cfg(not(feature = "no_std"))]
pub type StraightHashMap<K, V> = std::collections::HashMap<K, V, StraightHasherBuilder>;
#[cfg(not(feature = "no_std"))]
pub type StraightHashSet<K> = std::collections::HashSet<K, StraightHasherBuilder>;
/// Dummy hash value to map zeros to. This value can be anything.
///

View File

@@ -21,7 +21,7 @@ pub use callable_function::CallableFunction;
pub use func::Func;
pub use hashing::{
calc_fn_hash, calc_fn_params_hash, calc_qualified_fn_hash, calc_qualified_var_hash,
combine_hashes, get_hasher, StraightHashMap, StraightHashSet,
combine_hashes, get_hasher, StraightHashMap,
};
pub use native::{
locked_read, locked_write, shared_get_mut, shared_make_mut, shared_take, shared_take_or_clone,