From 77ccb8778f5e6c8b11035b67b4104381da938fb2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 17 Jul 2024 23:04:00 +0200 Subject: [PATCH] Reduced memory allocations --- src/build/expression/Expression.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/build/expression/Expression.go b/src/build/expression/Expression.go index 8f99725..60b3794 100644 --- a/src/build/expression/Expression.go +++ b/src/build/expression/Expression.go @@ -28,6 +28,10 @@ func NewLeaf(t token.Token) *Expression { // AddChild adds a child to the expression. func (expr *Expression) AddChild(child *Expression) { + if expr.Children == nil { + expr.Children = make([]*Expression, 0, 2) + } + expr.Children = append(expr.Children, child) child.Parent = expr }