From b972ccb3f62ab83cf85d99cea2ef4e85a419359a Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Mon, 25 Aug 2025 11:04:49 -0400 Subject: [PATCH] chore(planner/physical): simplify replace code (#19003) --- pkg/engine/planner/physical/plan.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/engine/planner/physical/plan.go b/pkg/engine/planner/physical/plan.go index c5bd16c1eb..18cbf8ce5f 100644 --- a/pkg/engine/planner/physical/plan.go +++ b/pkg/engine/planner/physical/plan.go @@ -207,11 +207,10 @@ func (p *Plan) eliminateNode(node Node) { parent := p.Parent(node) if parent != nil { idx := slices.Index(p.children[parent], node) - // First get rid of the node to be deleted - allChildren := append(p.children[parent][0:idx], p.children[parent][idx+1:]...) - // Then insert all the children of the node - allChildren = slices.Insert(allChildren, idx, p.children[node]...) - p.children[parent] = allChildren + + // Replace node's entry in the parent's children with the children of node. + oldChildren := p.children[parent] + p.children[parent] = slices.Replace(oldChildren, idx, idx+1, p.children[node]...) } for _, child := range p.Children(node) {