This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new e40f50b991 Minor: Use slice in `ConcreteTreeNode` (#10666)
e40f50b991 is described below

commit e40f50b99145bf1e0c9baf4f013bf143c04a7eda
Author: Peter Toth <[email protected]>
AuthorDate: Sun May 26 11:50:27 2024 +0200

    Minor: Use slice in `ConcreteTreeNode` (#10666)
---
 datafusion/common/src/tree_node.rs               | 4 ++--
 datafusion/physical-expr-common/src/tree_node.rs | 4 ++--
 datafusion/physical-plan/src/tree_node.rs        | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/datafusion/common/src/tree_node.rs 
b/datafusion/common/src/tree_node.rs
index 9d42f4fb1e..f0e889e7cf 100644
--- a/datafusion/common/src/tree_node.rs
+++ b/datafusion/common/src/tree_node.rs
@@ -903,7 +903,7 @@ impl<T: DynTreeNode + ?Sized> TreeNode for Arc<T> {
 /// involving payloads, by enforcing rules for detaching and reattaching child 
nodes.
 pub trait ConcreteTreeNode: Sized {
     /// Provides read-only access to child nodes.
-    fn children(&self) -> Vec<&Self>;
+    fn children(&self) -> &[Self];
 
     /// Detaches the node from its children, returning the node itself and its 
detached children.
     fn take_children(self) -> (Self, Vec<Self>);
@@ -917,7 +917,7 @@ impl<T: ConcreteTreeNode> TreeNode for T {
         &self,
         f: F,
     ) -> Result<TreeNodeRecursion> {
-        self.children().into_iter().apply_until_stop(f)
+        self.children().iter().apply_until_stop(f)
     }
 
     fn map_children<F: FnMut(Self) -> Result<Transformed<Self>>>(
diff --git a/datafusion/physical-expr-common/src/tree_node.rs 
b/datafusion/physical-expr-common/src/tree_node.rs
index 42dc6673af..5de6457b8e 100644
--- a/datafusion/physical-expr-common/src/tree_node.rs
+++ b/datafusion/physical-expr-common/src/tree_node.rs
@@ -84,8 +84,8 @@ impl<T: Display> Display for ExprContext<T> {
 }
 
 impl<T> ConcreteTreeNode for ExprContext<T> {
-    fn children(&self) -> Vec<&Self> {
-        self.children.iter().collect()
+    fn children(&self) -> &[Self] {
+        &self.children
     }
 
     fn take_children(mut self) -> (Self, Vec<Self>) {
diff --git a/datafusion/physical-plan/src/tree_node.rs 
b/datafusion/physical-plan/src/tree_node.rs
index 46460cbb66..d3b51062c2 100644
--- a/datafusion/physical-plan/src/tree_node.rs
+++ b/datafusion/physical-plan/src/tree_node.rs
@@ -86,8 +86,8 @@ impl<T: Display> Display for PlanContext<T> {
 }
 
 impl<T> ConcreteTreeNode for PlanContext<T> {
-    fn children(&self) -> Vec<&Self> {
-        self.children.iter().collect()
+    fn children(&self) -> &[Self] {
+        &self.children
     }
 
     fn take_children(mut self) -> (Self, Vec<Self>) {


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

Reply via email to