Use StaticVec to avoid most allocations with function arguments.

This commit is contained in:
Stephen Chung
2020-05-10 21:25:47 +08:00
parent 974512d650
commit 8aa0e2ceb4
7 changed files with 161 additions and 80 deletions

View File

@@ -724,7 +724,7 @@ fn parse_call_expr<'a>(
#[cfg(not(feature = "no_module"))]
let hash_fn_def = {
if let Some(modules) = modules.as_mut() {
modules.set_index(stack.find_module(&modules.get(0).0));
modules.set_index(stack.find_module(&modules.get_ref(0).0));
// Rust functions are indexed in two steps:
// 1) Calculate a hash in a similar manner to script-defined functions,
@@ -764,7 +764,7 @@ fn parse_call_expr<'a>(
#[cfg(not(feature = "no_module"))]
let hash_fn_def = {
if let Some(modules) = modules.as_mut() {
modules.set_index(stack.find_module(&modules.get(0).0));
modules.set_index(stack.find_module(&modules.get_ref(0).0));
// Rust functions are indexed in two steps:
// 1) Calculate a hash in a similar manner to script-defined functions,
@@ -1238,7 +1238,7 @@ fn parse_primary<'a>(
// Qualifiers + variable name
*hash = calc_fn_hash(modules.iter().map(|(v, _)| v.as_str()), name, empty());
modules.set_index(stack.find_module(&modules.get(0).0));
modules.set_index(stack.find_module(&modules.get_ref(0).0));
}
_ => (),
}
@@ -1446,7 +1446,7 @@ fn make_dot_expr(
#[cfg(feature = "no_module")]
unreachable!();
#[cfg(not(feature = "no_module"))]
return Err(PERR::PropertyExpected.into_err(x.1.unwrap().get(0).1));
return Err(PERR::PropertyExpected.into_err(x.1.unwrap().get_ref(0).1));
}
// lhs.dot_lhs.dot_rhs
(lhs, Expr::Dot(x)) => {