Skip to content

Commit

Permalink
use retain instead
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia committed Oct 8, 2023
1 parent 45a134d commit 2b84393
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/query/src/query_engine/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,14 @@ impl QueryEngineState {
}

fn remove_analyzer_rule(rules: &mut Vec<Arc<dyn AnalyzerRule + Send + Sync>>, name: &str) {
let mut index_to_move = None;
for (i, rule) in rules.iter().enumerate() {
if rule.name() == name {
index_to_move = Some(i);
break;
}
}
if let Some(index) = index_to_move {
let _ = rules.remove(index);
}
rules.retain(|rule| rule.name() != name);
}

fn remove_physical_optimize_rule(
rules: &mut Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
name: &str,
) {
let mut index_to_move = None;
for (i, rule) in rules.iter().enumerate() {
if rule.name() == name {
index_to_move = Some(i);
break;
}
}
if let Some(index) = index_to_move {
let _ = rules.remove(index);
}
rules.retain(|rule| rule.name() != name);
}

/// Register a udf function
Expand Down

0 comments on commit 2b84393

Please sign in to comment.