Use tokens to speed up function name lookup.
This commit is contained in:
@@ -117,7 +117,7 @@ impl Engine {
|
||||
global: &mut GlobalRuntimeState,
|
||||
caches: &mut Caches,
|
||||
lib: &[&Module],
|
||||
op_info: OpAssignment,
|
||||
op_info: &OpAssignment,
|
||||
target: &mut Target,
|
||||
root: (&str, Position),
|
||||
new_val: Dynamic,
|
||||
@@ -141,14 +141,15 @@ impl Engine {
|
||||
|
||||
let mut lock_guard = target.write_lock::<Dynamic>().unwrap();
|
||||
|
||||
let hash = hash_op_assign;
|
||||
let hash = *hash_op_assign;
|
||||
let args = &mut [&mut *lock_guard, &mut new_val];
|
||||
let level = level + 1;
|
||||
|
||||
if self.fast_operators() {
|
||||
if let Some(func) = get_builtin_op_assignment_fn(op_assign, args[0], args[1]) {
|
||||
// Built-in found
|
||||
let context = (self, op_assign, None, &*global, lib, op_pos, level).into();
|
||||
let op = op_assign.literal_syntax();
|
||||
let context = (self, op, None, &*global, lib, *op_pos, level).into();
|
||||
let result = func(context, args).map(|_| ());
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
@@ -158,8 +159,11 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
let op_assign = op_assign.literal_syntax();
|
||||
let op = op.literal_syntax();
|
||||
|
||||
match self.call_native_fn(
|
||||
global, caches, lib, op_assign, hash, args, true, true, op_pos, level,
|
||||
global, caches, lib, op_assign, hash, args, true, true, *op_pos, level,
|
||||
) {
|
||||
Ok(_) => {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
@@ -170,7 +174,7 @@ impl Engine {
|
||||
// Expand to `var = var op rhs`
|
||||
*args[0] = self
|
||||
.call_native_fn(
|
||||
global, caches, lib, op, hash_op, args, true, false, op_pos, level,
|
||||
global, caches, lib, op, *hash_op, args, true, false, *op_pos, level,
|
||||
)
|
||||
.map_err(|err| err.fill_position(op_info.pos))?
|
||||
.0
|
||||
@@ -279,7 +283,7 @@ impl Engine {
|
||||
let lhs_ptr = &mut lhs_ptr;
|
||||
|
||||
self.eval_op_assignment(
|
||||
global, caches, lib, *op_info, lhs_ptr, root, rhs_val, level,
|
||||
global, caches, lib, op_info, lhs_ptr, root, rhs_val, level,
|
||||
)
|
||||
.map(|_| Dynamic::UNIT)
|
||||
} else {
|
||||
@@ -303,7 +307,7 @@ impl Engine {
|
||||
rhs_val
|
||||
};
|
||||
|
||||
let _new_val = Some((rhs_val, *op_info));
|
||||
let _new_val = Some((rhs_val, op_info));
|
||||
|
||||
// Must be either `var[index] op= val` or `var.prop op= val`
|
||||
match lhs {
|
||||
|
Reference in New Issue
Block a user