Skip to content

Commit 6161772

Browse files
authored
Avoid allocating a bool for cached computed names (#65067)
1 parent f995d48 commit 6161772

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎tsc/internal/checker/checker.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19163,12 +19163,12 @@ func (c *Checker) getEffectivePropertyNameForPropertyNameNode(node *ast.Property
1916319163
case ast.IsComputedPropertyName(node):
1916419164
// This is cached so `getTypeOfExpression` isn't constantly reinvoked for every property name lookup
1916519165
links := c.computedNameLinks.Get(node)
19166-
if links != nil && links.hasName != nil {
19167-
return links.name, *links.hasName
19166+
if links != nil && !links.hasName.IsUnknown() {
19167+
return links.name, links.hasName.IsTrue()
1916819168
}
1916919169
name, exists := c.tryGetNameFromType(c.getTypeOfExpression(node.Expression()))
1917019170
links.name = name
19171-
links.hasName = &exists
19171+
links.hasName = core.BoolToTristate(exists)
1917219172
return name, exists
1917319173
}
1917419174
return "", false

‎tsc/internal/checker/types.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ func (links *TypeNodeLinks) setOuterTypeParameters(c *Checker, types []*Type) {
461461
}
462462

463463
type ComputedNameNodeLinks struct {
464-
hasName *bool // If the node has a computable name
465-
name string // Resolved name associated with the type of the node
464+
hasName core.Tristate // If the node has a computable name
465+
name string // Resolved name associated with the type of the node
466466
}
467467

468468
// Links for enum members

0 commit comments

Comments
 (0)