Skip to content

Commit e40f50b

Browse files
authored
Minor: Use slice in ConcreteTreeNode (#10666)
1 parent ea92ae7 commit e40f50b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

datafusion/common/src/tree_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ impl<T: DynTreeNode + ?Sized> TreeNode for Arc<T> {
903903
/// involving payloads, by enforcing rules for detaching and reattaching child nodes.
904904
pub trait ConcreteTreeNode: Sized {
905905
/// Provides read-only access to child nodes.
906-
fn children(&self) -> Vec<&Self>;
906+
fn children(&self) -> &[Self];
907907

908908
/// Detaches the node from its children, returning the node itself and its detached children.
909909
fn take_children(self) -> (Self, Vec<Self>);
@@ -917,7 +917,7 @@ impl<T: ConcreteTreeNode> TreeNode for T {
917917
&self,
918918
f: F,
919919
) -> Result<TreeNodeRecursion> {
920-
self.children().into_iter().apply_until_stop(f)
920+
self.children().iter().apply_until_stop(f)
921921
}
922922

923923
fn map_children<F: FnMut(Self) -> Result<Transformed<Self>>>(

datafusion/physical-expr-common/src/tree_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl<T: Display> Display for ExprContext<T> {
8484
}
8585

8686
impl<T> ConcreteTreeNode for ExprContext<T> {
87-
fn children(&self) -> Vec<&Self> {
88-
self.children.iter().collect()
87+
fn children(&self) -> &[Self] {
88+
&self.children
8989
}
9090

9191
fn take_children(mut self) -> (Self, Vec<Self>) {

datafusion/physical-plan/src/tree_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl<T: Display> Display for PlanContext<T> {
8686
}
8787

8888
impl<T> ConcreteTreeNode for PlanContext<T> {
89-
fn children(&self) -> Vec<&Self> {
90-
self.children.iter().collect()
89+
fn children(&self) -> &[Self] {
90+
&self.children
9191
}
9292

9393
fn take_children(mut self) -> (Self, Vec<Self>) {

0 commit comments

Comments
 (0)