Skip to content

Commit 672d2a2

Browse files
committed
perf(syntax): avoid array spread in PathExpression.original getter
The getter on `PathExpression` in `legacy-interop.ts` is read once or more per path node visit by every Ember template plugin. Its previous form allocated a fresh array on every call: return [this.head.original, ...this.tail].join('.'); Replace with a direct head return for the empty-tail case and a string concat for the rest: const head = this.head.original; return this.tail.length === 0 ? head : head + '.' + this.tail.join('.'); No behaviour change — both forms return the same string for every (head, tail). See PR description for the equivalence proof and the before/after measurements.
1 parent 0d73c63 commit 672d2a2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/@glimmer/syntax/lib/v1/legacy-interop.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export function buildLegacyPath({ head, tail, loc }: PathExpressionParams): ASTv
4848
head,
4949
tail,
5050
get original() {
51-
return [this.head.original, ...this.tail].join('.');
51+
const head = this.head.original;
52+
return this.tail.length === 0 ? head : `${head}.${this.tail.join('.')}`;
5253
},
5354
set original(value: string) {
5455
let [head, ...tail] = asPresentArray(value.split('.'));

0 commit comments

Comments
 (0)