Skip to content

Commit c07f0af

Browse files
TCeasondrmingdrmer
authored andcommitted
use btreeset replace vec
1 parent f008f4b commit c07f0af

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/query/storages/system/src/tables_table.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::collections::BTreeSet;
1516
use std::collections::HashMap;
1617
use std::collections::HashSet;
1718
use std::sync::Arc;
@@ -252,7 +253,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
252253
let user_api = UserApiProvider::instance();
253254

254255
let mut dbs = Vec::new();
255-
let mut tables_names: Vec<String> = Vec::new();
256+
let mut tables_names: BTreeSet<String> = BTreeSet::new();
256257
let mut invalid_tables_ids = false;
257258
let mut tables_ids: Vec<u64> = Vec::new();
258259
let mut db_name: Vec<String> = Vec::new();
@@ -318,7 +319,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
318319
} else if col_name == "name" {
319320
if let Scalar::String(t_name) = scalar {
320321
if !tables_names.contains(t_name) {
321-
tables_names.push(t_name.clone());
322+
tables_names.insert(t_name.clone());
322323
}
323324
}
324325
}
@@ -353,12 +354,8 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
353354
.await
354355
{
355356
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();
362359
tables_names.extend(new_table_names);
363360
}
364361
Err(err) => {
@@ -442,7 +439,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
442439
Ok(tables) => {
443440
for table in tables.into_iter().flatten() {
444441
if !tables_names.contains(&table) {
445-
tables_names.push(table.clone());
442+
tables_names.insert(table.clone());
446443
}
447444
}
448445
}

0 commit comments

Comments
 (0)