From 43c4d7e3ca70e020c639dac9ab2f293fca1005b8 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 3 Sep 2022 12:35:00 +0800 Subject: [PATCH] Use standard operator to short-circuit. --- src/eval/expr.rs | 8 ++++---- src/func/call.rs | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/eval/expr.rs b/src/eval/expr.rs index 4748e0c5..09231462 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -222,14 +222,14 @@ impl Engine { #[cfg(not(feature = "no_module"))] namespace, capture_parent_scope: capture, - is_standard_operator, + is_standard_operator: std_ops, hashes, args, .. } = expr; #[cfg(feature = "fast_ops")] - if *is_standard_operator { + if *std_ops { let mut lhs = self .get_arg_value(scope, global, caches, lib, this_ptr, &args[0], level)? .0 @@ -311,8 +311,8 @@ impl Engine { ); self.make_function_call( - scope, global, caches, lib, this_ptr, name, first_arg, args, *hashes, *capture, pos, - level, + scope, global, caches, lib, this_ptr, name, first_arg, args, *hashes, *capture, + *std_ops, pos, level, ) } diff --git a/src/func/call.rs b/src/func/call.rs index 2662cc80..5bd4616c 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -989,6 +989,7 @@ impl Engine { args_expr: &[Expr], hashes: FnCallHashes, capture_scope: bool, + is_standard_operator: bool, pos: Position, level: usize, ) -> RhaiResult { @@ -1001,6 +1002,8 @@ impl Engine { let redirected; // Handle call() - Redirect function call match name { + _ if is_standard_operator => (), + // Handle call() KEYWORD_FN_PTR_CALL if total_args >= 1 => { let arg = first_arg.unwrap();