diff --git a/src/libexpr/include/nix/expr/nixexpr.hh b/src/libexpr/include/nix/expr/nixexpr.hh index fd7ed2a6745..afaf50b2b11 100644 --- a/src/libexpr/include/nix/expr/nixexpr.hh +++ b/src/libexpr/include/nix/expr/nixexpr.hh @@ -760,11 +760,19 @@ struct ExprConcatStrings : Expr { PosIdx pos; bool forceString; - std::vector> es; - ExprConcatStrings(const PosIdx & pos, bool forceString, std::vector> && es) + std::span> es; + + ExprConcatStrings( + std::pmr::polymorphic_allocator & alloc, + const PosIdx & pos, + bool forceString, + const std::vector> & es) : pos(pos) , forceString(forceString) - , es(std::move(es)) {}; + , es({alloc.allocate_object>(es.size()), es.size()}) + { + std::ranges::copy(es, this->es.begin()); + }; PosIdx getPos() const override { diff --git a/src/libexpr/include/nix/expr/parser-state.hh b/src/libexpr/include/nix/expr/parser-state.hh index 4cffaa49779..e303b81ce5c 100644 --- a/src/libexpr/include/nix/expr/parser-state.hh +++ b/src/libexpr/include/nix/expr/parser-state.hh @@ -341,7 +341,7 @@ ParserState::stripIndentation(const PosIdx pos, std::vectorat(@2), $1, $3); } | expr_op '?' attrpath { $$ = new ExprOpHasAttr(state->alloc, $1, std::move($3)); } | expr_op '+' expr_op - { $$ = new ExprConcatStrings(state->at(@2), false, {{state->at(@1), $1}, {state->at(@3), $3}}); } + { $$ = new ExprConcatStrings(state->alloc, state->at(@2), false, {{state->at(@1), $1}, {state->at(@3), $3}}); } | expr_op '-' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.sub), {$1, $3}); } | expr_op '*' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.mul), {$1, $3}); } | expr_op '/' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.div), {$1, $3}); } @@ -309,7 +309,7 @@ expr_simple | path_start PATH_END | path_start string_parts_interpolated PATH_END { $2.insert($2.begin(), {state->at(@1), $1}); - $$ = new ExprConcatStrings(CUR_POS, false, std::move($2)); + $$ = new ExprConcatStrings(state->alloc, CUR_POS, false, std::move($2)); } | SPATH { std::string_view path($1.p + 1, $1.l - 2); @@ -343,7 +343,7 @@ expr_simple string_parts : STR { $$ = $1; } - | string_parts_interpolated { $$ = new ExprConcatStrings(CUR_POS, true, std::move($1)); } + | string_parts_interpolated { $$ = new ExprConcatStrings(state->alloc, CUR_POS, true, std::move($1)); } | { $$ = std::string_view(); } ;