Reduced memory allocations
This commit is contained in:
parent
6e3cc26092
commit
77ccb8778f
1 changed files with 4 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue