|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
| 15 | +use std::collections::BTreeSet; |
15 | 16 | use std::collections::HashMap; |
16 | 17 | use std::collections::HashSet; |
17 | 18 | use std::sync::Arc; |
@@ -252,7 +253,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware |
252 | 253 | let user_api = UserApiProvider::instance(); |
253 | 254 |
|
254 | 255 | let mut dbs = Vec::new(); |
255 | | - let mut tables_names: Vec<String> = Vec::new(); |
| 256 | + let mut tables_names: BTreeSet<String> = BTreeSet::new(); |
256 | 257 | let mut invalid_tables_ids = false; |
257 | 258 | let mut tables_ids: Vec<u64> = Vec::new(); |
258 | 259 | let mut db_name: Vec<String> = Vec::new(); |
@@ -318,7 +319,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware |
318 | 319 | } else if col_name == "name" { |
319 | 320 | if let Scalar::String(t_name) = scalar { |
320 | 321 | if !tables_names.contains(t_name) { |
321 | | - tables_names.push(t_name.clone()); |
| 322 | + tables_names.insert(t_name.clone()); |
322 | 323 | } |
323 | 324 | } |
324 | 325 | } |
@@ -353,12 +354,8 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware |
353 | 354 | .await |
354 | 355 | { |
355 | 356 | Ok(new_tables) => { |
356 | | - let new_table_names: Vec<_> = new_tables |
357 | | - .into_iter() |
358 | | - .flatten() |
359 | | - .filter(|table| !tables_names.contains(table)) |
360 | | - .collect(); |
361 | | - |
| 357 | + let new_table_names: BTreeSet<_> = |
| 358 | + new_tables.into_iter().flatten().collect(); |
362 | 359 | tables_names.extend(new_table_names); |
363 | 360 | } |
364 | 361 | Err(err) => { |
@@ -442,7 +439,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware |
442 | 439 | Ok(tables) => { |
443 | 440 | for table in tables.into_iter().flatten() { |
444 | 441 | if !tables_names.contains(&table) { |
445 | | - tables_names.push(table.clone()); |
| 442 | + tables_names.insert(table.clone()); |
446 | 443 | } |
447 | 444 | } |
448 | 445 | } |
|
0 commit comments