Skip to content

Commit

Permalink
Minor: Use slice in ConcreteTreeNode (apache#10666)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-toth authored and jayzhan211 committed May 26, 2024
1 parent 4ec58ae commit 30e9655
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions datafusion/common/src/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
Expand All @@ -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>>>(
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-expr-common/src/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-plan/src/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand Down

0 comments on commit 30e9655

Please sign in to comment.