Reduced memory allocations
This commit is contained in:
parent
6e3cc26092
commit
77ccb8778f
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user