Skip to content

Commit

Permalink
Merge pull request #1344 from chriskrycho/syntax-cache-head
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored Oct 4, 2021
2 parents f593ec6 + 729077d commit 847dec7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@glimmer/syntax/lib/v1/legacy-interop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ export class PathExpressionImplV1 implements PathExpression {
this.parts = parts;
}

// Cache for the head value.
_head?: PathHead = undefined;

get head(): PathHead {
if (this._head) {
return this._head;
}

let firstPart: string;

if (this.this) {
Expand All @@ -38,7 +45,7 @@ export class PathExpressionImplV1 implements PathExpression {
chars: firstPart.length,
}).loc;

return b.head(firstPart, firstPartLoc);
return (this._head = b.head(firstPart, firstPartLoc));
}

get tail(): string[] {
Expand Down

0 comments on commit 847dec7

Please sign in to comment.