Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool some more nodes in test profile #360

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
15 changes: 10 additions & 5 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ type NodeFactory struct {
expressionStatementPool core.Pool[ExpressionStatement]
identifierPool core.Pool[Identifier]
ifStatementPool core.Pool[IfStatement]
interfaceDeclarationPool core.Pool[InterfaceDeclaration]
jsdocPool core.Pool[JSDoc]
jsdocTextPool core.Pool[JSDocText]
keywordExpressionPool core.Pool[KeywordExpression]
keywordTypeNodePool core.Pool[KeywordTypeNode]
literalTypeNodePool core.Pool[LiteralTypeNode]
methodSignatureDeclarationPool core.Pool[MethodSignatureDeclaration]
modifierListPool core.Pool[ModifierList]
nodeListPool core.Pool[NodeList]
numericLiteralPool core.Pool[NumericLiteral]
parameterDeclarationPool core.Pool[ParameterDeclaration]
parenthesizedExpressionPool core.Pool[ParenthesizedExpression]
propertyAccessExpressionPool core.Pool[PropertyAccessExpression]
Expand All @@ -69,6 +73,7 @@ type NodeFactory struct {
stringLiteralPool core.Pool[StringLiteral]
tokenPool core.Pool[Token]
typeReferenceNodePool core.Pool[TypeReferenceNode]
unionTypeNodePool core.Pool[UnionTypeNode]
variableDeclarationListPool core.Pool[VariableDeclarationList]
variableDeclarationPool core.Pool[VariableDeclaration]
variableStatementPool core.Pool[VariableStatement]
Expand Down Expand Up @@ -3189,7 +3194,7 @@ type InterfaceDeclaration struct {
}

func (f *NodeFactory) NewInterfaceDeclaration(modifiers *ModifierList, name *IdentifierNode, typeParameters *NodeList, heritageClauses *NodeList, members *NodeList) *Node {
data := &InterfaceDeclaration{}
data := f.interfaceDeclarationPool.New()
data.modifiers = modifiers
data.name = name
data.TypeParameters = typeParameters
Expand Down Expand Up @@ -4284,7 +4289,7 @@ type MethodSignatureDeclaration struct {
}

func (f *NodeFactory) NewMethodSignatureDeclaration(modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, typeParameters *NodeList, parameters *NodeList, returnType *TypeNode) *Node {
data := &MethodSignatureDeclaration{}
data := f.methodSignatureDeclarationPool.New()
data.modifiers = modifiers
data.name = name
data.PostfixToken = postfixToken
Expand Down Expand Up @@ -4545,7 +4550,7 @@ type KeywordExpression struct {
}

func (f *NodeFactory) NewKeywordExpression(kind Kind) *Node {
return newNode(kind, &KeywordExpression{}, f.hooks)
return newNode(kind, f.keywordExpressionPool.New(), f.hooks)
}

func (node *KeywordExpression) Clone(f *NodeFactory) *Node {
Expand Down Expand Up @@ -4590,7 +4595,7 @@ type NumericLiteral struct {
}

func (f *NodeFactory) NewNumericLiteral(text string) *Node {
data := &NumericLiteral{}
data := f.numericLiteralPool.New()
data.Text = text
return newNode(KindNumericLiteral, data, f.hooks)
}
Expand Down Expand Up @@ -5885,7 +5890,7 @@ func (f *NodeFactory) UpdateUnionTypeNode(node *UnionTypeNode, types *TypeList)
}

func (f *NodeFactory) NewUnionTypeNode(types *NodeList) *Node {
data := &UnionTypeNode{}
data := f.unionTypeNodePool.New()
data.Types = types
return newNode(KindUnionType, data, f.hooks)
}
Expand Down