Skip to content

Commit 847dec7

Browse files
authored
Merge pull request #1344 from chriskrycho/syntax-cache-head
2 parents f593ec6 + 729077d commit 847dec7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ export class PathExpressionImplV1 implements PathExpression {
2323
this.parts = parts;
2424
}
2525

26+
// Cache for the head value.
27+
_head?: PathHead = undefined;
28+
2629
get head(): PathHead {
30+
if (this._head) {
31+
return this._head;
32+
}
33+
2734
let firstPart: string;
2835

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

41-
return b.head(firstPart, firstPartLoc);
48+
return (this._head = b.head(firstPart, firstPartLoc));
4249
}
4350

4451
get tail(): string[] {

0 commit comments

Comments
 (0)