Skip to content

Commit

Permalink
avoid clone in replace_sort_expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 28, 2024
1 parent 1e3ca00 commit 2f0ea05
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions datafusion/expr/src/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ pub fn transform_sort_vec<F: FnMut(Expr) -> Result<Transformed<Expr>>>(

pub fn replace_sort_expressions(sorts: Vec<Sort>, new_expr: Vec<Expr>) -> Vec<Sort> {
assert_eq!(sorts.len(), new_expr.len());
let mut new_sorts = Vec::with_capacity(sorts.len());
for (i, expr) in new_expr.into_iter().enumerate() {
new_sorts.push(replace_sort_expression(sorts[i].clone(), expr));
}
new_sorts
sorts
.into_iter()
.zip(new_expr)
.map(|(sort, expr)| replace_sort_expression(sort, expr))
.collect()
}

pub fn replace_sort_expression(sort: Sort, new_expr: Expr) -> Sort {
Expand Down

0 comments on commit 2f0ea05

Please sign in to comment.