Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmicu committed Dec 14, 2023
1 parent 63a425d commit bde8501
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,14 +829,17 @@ impl Valve {

let setup_statements = self.get_setup_statements().await?;
let sorted_table_list = self.get_tables_ordered_for_creation();
let mut once_dropped = false;
for (i, table) in sorted_table_list.iter().enumerate() {
if self.table_has_changed(*table).await? {
let mut tables_to_drop = vec![""; sorted_table_list.len() - i];
tables_to_drop.clone_from_slice(&sorted_table_list[i..]);
tables_to_drop.reverse();
for table in tables_to_drop {
valve_log!("Dropping table {}", table);
self.drop_tables(vec![table]).await?;
if !once_dropped {
let mut tables_to_drop = vec![""; sorted_table_list.len() - i];
tables_to_drop.clone_from_slice(&sorted_table_list[i..]);
tables_to_drop.reverse();
for table in tables_to_drop {
self.drop_tables(vec![table]).await?;
}
once_dropped = true;
}

let table_statements = setup_statements.get(*table).unwrap();
Expand Down

0 comments on commit bde8501

Please sign in to comment.