rohitrastogi commented on code in PR #10305:
URL: https://github.com/apache/datafusion/pull/10305#discussion_r1583964858


##########
datafusion/optimizer/src/rewrite_disjunctive_predicate.rs:
##########
@@ -305,31 +316,30 @@ fn delete_duplicate_predicates(or_predicates: 
&[Predicate]) -> Predicate {
     }
     if exist_exprs.is_empty() {
         return Predicate::Or {
-            args: or_predicates.to_vec(),
+            args: or_predicates,
         };
     }
 
     // Rebuild the OR predicate.
     // (A AND B) OR A will be optimized to A.
     let mut new_or_predicates = vec![];
-    for or_predicate in or_predicates.iter() {
+    for or_predicate in or_predicates.into_iter() {
         match or_predicate {
-            Predicate::And { args } => {
-                let mut new_args = (*args).clone();
-                new_args.retain(|expr| !exist_exprs.contains(expr));
-                if !new_args.is_empty() {
-                    if new_args.len() == 1 {
-                        new_or_predicates.push(new_args[0].clone());
+            Predicate::And { mut args } => {
+                args.retain(|expr| !exist_exprs.contains(expr));
+                if !args.is_empty() {
+                    if args.len() == 1 {
+                        new_or_predicates.push(args.remove(0));

Review Comment:
   I believe remove() should be O(1) here and below as there's just one item in 
the vector.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to