Fix no_closure build.

This commit is contained in:
Stephen Chung 2021-09-26 21:30:33 +08:00
parent a130960627
commit 42d3fde0af
2 changed files with 5 additions and 3 deletions

View File

@ -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) => {

View File

@ -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(_, _)) => {