Skip to content

Commit

Permalink
reduce cloning in EliminateDuplicatedExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 28, 2024
1 parent 39877e4 commit 09b20d5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions datafusion/optimizer/src/eliminate_duplicated_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ impl OptimizerRule for EliminateDuplicatedExpr {
match plan {
LogicalPlan::Sort(sort) => {
let len = sort.expr.len();
let mut first_sort_by_expr: IndexMap<Expr, SortExpr> =
let mut first_sort_by_expr: IndexMap<&Expr, &SortExpr> =
IndexMap::default();
for s in &sort.expr {
first_sort_by_expr
.entry(s.expr.as_ref().clone())
.or_insert(s.clone());
first_sort_by_expr.entry(s.expr.as_ref()).or_insert(s);
}
let unique_exprs: Vec<SortExpr> =
first_sort_by_expr.into_values().collect();
first_sort_by_expr.into_values().cloned().collect();

let transformed = if len != unique_exprs.len() {
Transformed::yes
Expand Down

0 comments on commit 09b20d5

Please sign in to comment.