Reduced memory allocations

This commit is contained in:
Eduard Urbach 2024-07-17 23:04:00 +02:00
parent 6e3cc26092
commit 77ccb8778f
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -28,6 +28,10 @@ func NewLeaf(t token.Token) *Expression {
// AddChild adds a child to the expression. // AddChild adds a child to the expression.
func (expr *Expression) AddChild(child *Expression) { func (expr *Expression) AddChild(child *Expression) {
if expr.Children == nil {
expr.Children = make([]*Expression, 0, 2)
}
expr.Children = append(expr.Children, child) expr.Children = append(expr.Children, child)
child.Parent = expr child.Parent = expr
} }