From b0cdd35de4e712c604a6c1783fb450e913206bd0 Mon Sep 17 00:00:00 2001 From: guangwu Date: Thu, 2 May 2024 16:02:33 +0800 Subject: [PATCH] chore: slice append replace loop (#588) --- planner/core/rule_predicate_push_down.go | 8 ++------ store/mockstore/mocktikv/executor.go | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/planner/core/rule_predicate_push_down.go b/planner/core/rule_predicate_push_down.go index ab8c9a729..f5c9506ba 100644 --- a/planner/core/rule_predicate_push_down.go +++ b/planner/core/rule_predicate_push_down.go @@ -75,9 +75,7 @@ func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression) func (p *LogicalUnionScan) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan) { retainedPredicates, _ := p.children[0].PredicatePushDown(predicates) p.conditions = make([]expression.Expression, 0, len(predicates)) - for _, cond := range predicates { - p.conditions = append(p.conditions, cond) - } + p.conditions = append(p.conditions, predicates...) // The conditions in UnionScan is only used for added rows, so parent Selection should not be removed. return retainedPredicates, p } @@ -317,9 +315,7 @@ func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression func (p *LogicalUnionAll) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan) { for i, proj := range p.children { newExprs := make([]expression.Expression, 0, len(predicates)) - for _, cond := range predicates { - newExprs = append(newExprs, cond) - } + newExprs = append(newExprs, predicates...) retCond, newChild := proj.PredicatePushDown(newExprs) addSelection(p, newChild, retCond, i) } diff --git a/store/mockstore/mocktikv/executor.go b/store/mockstore/mocktikv/executor.go index 655ff5572..3d8b13940 100644 --- a/store/mockstore/mocktikv/executor.go +++ b/store/mockstore/mocktikv/executor.go @@ -566,9 +566,7 @@ func (e *topNExec) evalTopN(value [][]byte) error { } if e.heap.tryToAddRow(newRow) { - for _, val := range value { - newRow.data = append(newRow.data, val) - } + newRow.data = append(newRow.data, value...) } return errors.Trace(e.heap.err) }