aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/parser.y
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-06-16 23:10:09 +0200
committereldritch horrors <pennae@lix.systems>2024-06-17 19:46:44 +0000
commitb8f49a8eaf619df6d228f2e0f9814c4a5fa4aec5 (patch)
tree311d001ae953e0f8d750ec59a124c0a737b083f0 /src/libexpr/parser.y
parentdad8bc679e9f7bd97442249293138c7a2af311e4 (diff)
libexpr: store ExprConcatStrings elements as direct vector
storing a pointer only adds an unnecessary indirection at runtime. Change-Id: If06dd05effdf1ccb0df0873580f50c775608925d
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r--src/libexpr/parser.y10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 7783d2c20..5b53720ce 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -209,7 +209,7 @@ expr_op
| expr_op UPDATE expr_op { $$ = new ExprOpUpdate(state->at(@2), $1, $3); }
| expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, std::move(*$3)); delete $3; }
| expr_op '+' expr_op
- { $$ = new ExprConcatStrings(state->at(@2), false, new std::vector<std::pair<PosIdx, Expr *> >({{state->at(@1), $1}, {state->at(@3), $3}})); }
+ { $$ = new ExprConcatStrings(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}); }
@@ -258,7 +258,8 @@ 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, $2);
+ $$ = new ExprConcatStrings(CUR_POS, false, std::move(*$2));
+ delete $2;
}
| SPATH {
std::string path($1.p + 1, $1.l - 2);
@@ -290,7 +291,10 @@ expr_simple
string_parts
: STR { $$ = new ExprString(std::string($1)); }
- | string_parts_interpolated { $$ = new ExprConcatStrings(CUR_POS, true, $1); }
+ | string_parts_interpolated
+ { $$ = new ExprConcatStrings(CUR_POS, true, std::move(*$1));
+ delete $1;
+ }
| { $$ = new ExprString(""); }
;