From c82f07830728580aac96f3d18ab18b9e280e1212 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Sun, 11 Feb 2024 15:07:37 -0500 Subject: [PATCH] two clippy changes --- optd-core/src/cascades/memo.rs | 14 +++++--------- optd-core/src/cascades/tasks/optimize_inputs.rs | 3 +-- optd-datafusion-repr/src/properties/schema.rs | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/optd-core/src/cascades/memo.rs b/optd-core/src/cascades/memo.rs index 3f406f42..d6afbed5 100644 --- a/optd-core/src/cascades/memo.rs +++ b/optd-core/src/cascades/memo.rs @@ -204,13 +204,10 @@ impl Memo { group_id: ReducedGroupId, memo_node: RelMemoNode, ) { - match self.groups.entry(group_id) { - Entry::Occupied(mut entry) => { - let group = entry.get_mut(); - group.group_exprs.insert(expr_id); - return; - } - _ => {} + if let Entry::Occupied(mut entry) = self.groups.entry(group_id) { + let group = entry.get_mut(); + group.group_exprs.insert(expr_id); + return; } let mut group = Group { group_exprs: HashSet::new(), @@ -423,8 +420,7 @@ impl Memo { if !winner.impossible { let expr_id = winner.expr_id; let expr = self.get_expr_memoed(expr_id); - let mut children = Vec::new(); - children.reserve(expr.children.len()); + let mut children = Vec::with_capacity(expr.children.len()); for child in &expr.children { children.push(self.get_best_group_binding(*child, on_produce)?); } diff --git a/optd-core/src/cascades/tasks/optimize_inputs.rs b/optd-core/src/cascades/tasks/optimize_inputs.rs index 2a3368f6..6cb6b85a 100644 --- a/optd-core/src/cascades/tasks/optimize_inputs.rs +++ b/optd-core/src/cascades/tasks/optimize_inputs.rs @@ -51,8 +51,7 @@ impl OptimizeInputsTask { optimizer: &mut CascadesOptimizer, ) -> Vec { let zero_cost = optimizer.cost().zero(); - let mut input_cost = Vec::new(); - input_cost.reserve(children.len()); + let mut input_cost = Vec::with_capacity(children.len()); for &child in children.iter() { let group = optimizer.get_group_info(child); if let Some(ref winner) = group.winner { diff --git a/optd-datafusion-repr/src/properties/schema.rs b/optd-datafusion-repr/src/properties/schema.rs index 1b262c1a..09ff2eee 100644 --- a/optd-datafusion-repr/src/properties/schema.rs +++ b/optd-datafusion-repr/src/properties/schema.rs @@ -10,6 +10,10 @@ impl Schema { pub fn len(&self) -> usize { self.0.len() } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } } pub trait Catalog: Send + Sync + 'static {