perf: pre-allocate all known length arrays to avoid re-scaling (#5029)

Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
Ioannis Pinakoulakis
2025-08-08 19:03:25 +03:00
committed by GitHub
parent a2b98dbcf7
commit 130e1ba963
19 changed files with 29 additions and 28 deletions

View File

@@ -126,7 +126,7 @@ func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) any {
// VisitTypeBlock implements from api.BaseApiParserVisitor
func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) any {
list := ctx.AllTypeBlockBody()
var types []TypeExpr
types := make([]TypeExpr, 0, len(list))
for _, each := range list {
types = append(types, each.Accept(v).(TypeExpr))
}