From 2de4325d7eb010ff1aaca1ee775504cb7c8b95c2 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 3 Sep 2022 15:31:29 +0800 Subject: [PATCH] Use fast operators mode in rhai-run. --- src/bin/rhai-run.rs | 2 ++ src/eval/expr.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/bin/rhai-run.rs b/src/bin/rhai-run.rs index e87e99b4..e44a3b7f 100644 --- a/src/bin/rhai-run.rs +++ b/src/bin/rhai-run.rs @@ -50,6 +50,8 @@ fn main() { // Initialize scripting engine let mut engine = Engine::new(); + engine.set_fast_operators(true); + #[cfg(not(feature = "no_optimize"))] engine.set_optimization_level(rhai::OptimizationLevel::Simple); diff --git a/src/eval/expr.rs b/src/eval/expr.rs index 661534a7..48f870a4 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -228,6 +228,7 @@ impl Engine { .. } = expr; + // Short-circuit operator call if under Fast Operators mode if *std_ops && self.fast_operators() { let mut lhs = self .get_arg_value(scope, global, caches, lib, this_ptr, &args[0], level)?