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

@@ -66,13 +66,13 @@ impl Ord for FnMetadata<'_> {
impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
fn from(info: &'a FuncInfo) -> Self {
let base_hash = calc_fn_hash(&info.metadata.name, info.metadata.params);
let base_hash = calc_fn_hash(&info.name, info.num_params);
let (typ, full_hash) = if info.func.is_script() {
(FnType::Script, base_hash)
} else {
(
FnType::Native,
calc_native_fn_hash(None, &info.metadata.name, &info.param_types),
calc_native_fn_hash(None, &info.name, &info.param_types),
)
};
@@ -80,13 +80,12 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
base_hash,
full_hash,
#[cfg(not(feature = "no_module"))]
namespace: info.metadata.namespace,
access: info.metadata.access,
name: &info.metadata.name,
namespace: info.namespace,
access: info.access,
name: &info.name,
typ,
num_params: info.metadata.params,
num_params: info.num_params,
params: info
.metadata
.params_info
.iter()
.map(|s| {
@@ -100,7 +99,7 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
})
.collect(),
_dummy: None,
return_type: format_type(&info.metadata.return_type, true),
return_type: format_type(&info.return_type, true),
signature: info.gen_signature().into(),
doc_comments: if info.func.is_script() {
#[cfg(feature = "no_function")]
@@ -115,7 +114,7 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
.map(<_>::as_ref)
.collect()
} else {
info.metadata.comments.iter().map(<_>::as_ref).collect()
info.comments.iter().map(<_>::as_ref).collect()
},
}
}