From 42d3fde0af7adf0386b6071e2c217f571d0c46ed Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 26 Sep 2021 21:30:33 +0800 Subject: [PATCH] Fix no_closure build. --- src/engine.rs | 6 ++++-- src/optimize.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index 0b8b2740..7b891f2f 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -2090,7 +2090,7 @@ impl Engine { // `... ${...} ...` Expr::InterpolatedString(x, pos) => { let mut pos = *pos; - let mut result: Dynamic = self.const_empty_string().clone().into(); + let mut result: Dynamic = self.const_empty_string().into(); for expr in x.iter() { let item = self.eval_expr(scope, mods, state, lib, this_ptr, expr, level)?; @@ -3041,7 +3041,9 @@ impl Engine { match result { // Concentrate all empty strings into one instance to save memory #[cfg(feature = "no_closure")] - Ok(r) if r.as_str_ref().map_or(false, &str::is_empty) => Ok(self.empty_string().into()), + Ok(r) if r.as_str_ref().map_or(false, &str::is_empty) => { + Ok(self.const_empty_string().into()) + } // Concentrate all empty strings into one instance to save memory #[cfg(not(feature = "no_closure"))] Ok(r) if !r.is_shared() && r.as_str_ref().map_or(false, &str::is_empty) => { diff --git a/src/optimize.rs b/src/optimize.rs index d4ec1945..22878f5b 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -822,7 +822,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) { // `` Expr::InterpolatedString(x, pos) if x.is_empty() => { state.set_dirty(); - *expr = Expr::StringConstant(state.engine.const_empty_string().clone(), *pos); + *expr = Expr::StringConstant(state.engine.const_empty_string(), *pos); } // `...` Expr::InterpolatedString(x, _) if x.len() == 1 && matches!(x[0], Expr::StringConstant(_, _)) => {