aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEt7f3 <cadeaudeelie@gmail.com>2023-02-11 00:34:31 +0100
committerEt7f3 <cadeaudeelie@gmail.com>2023-02-12 05:49:45 +0100
commitfa89d317b7c7590a59db44bb369fcfe6baee4296 (patch)
treea09394b6c944cc273f8db7630cd2826fb4e31280
parent3d16f2a2810a755b066738f3163abe7bd0d636ff (diff)
ExprString: Avoid copy of string
-rw-r--r--src/libexpr/nixexpr.hh2
-rw-r--r--src/libexpr/parser.y4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index ffe67f97d..20a586f60 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -186,7 +186,7 @@ struct ExprString : Expr
{
std::string s;
Value v;
- ExprString(std::string s) : s(std::move(s)) { v.mkString(this->s.data()); };
+ ExprString(std::string &&s) : s(std::move(s)) { v.mkString(this->s.data()); };
Value * maybeThunk(EvalState & state, Env & env) override;
COMMON_METHODS
};
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 6f1041d2d..1dd4a801f 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -268,7 +268,7 @@ static Expr * stripIndentation(const PosIdx pos, SymbolTable & symbols,
s2 = std::string(s2, 0, p + 1);
}
- es2->emplace_back(i->first, new ExprString(s2));
+ es2->emplace_back(i->first, new ExprString(std::move(s2)));
};
for (; i != es.end(); ++i, --n) {
std::visit(overloaded { trimExpr, trimString }, i->second);
@@ -465,7 +465,7 @@ expr_simple
$$ = new ExprCall(CUR_POS,
new ExprVar(data->symbols.create("__findFile")),
{new ExprVar(data->symbols.create("__nixPath")),
- new ExprString(path)});
+ new ExprString(std::move(path))});
}
| URI {
static bool noURLLiterals = settings.isExperimentalFeatureEnabled(Xp::NoUrlLiterals);