Skip to content

Commit 0710ebb

Browse files
committed
don't collect found paths into BTreeSet:
keeping order of inserted Paths having high cost on hot path, collect into HashSet instead and sort afterward. from 1,858,963,938 to 1,448,975,825 I refs.
1 parent e78d685 commit 0710ebb

File tree

1 file changed

+6
-5
lines changed
  • src/tools/compiletest/src

1 file changed

+6
-5
lines changed

src/tools/compiletest/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files};
2525
use core::panic;
2626
use getopts::Options;
2727
use lazycell::AtomicLazyCell;
28-
use std::collections::BTreeSet;
28+
use std::collections::HashSet;
2929
use std::ffi::OsString;
3030
use std::fs;
3131
use std::io::{self, ErrorKind};
@@ -415,7 +415,7 @@ pub fn run_tests(config: Arc<Config>) {
415415

416416
let mut tests = Vec::new();
417417
for c in configs {
418-
let mut found_paths = BTreeSet::new();
418+
let mut found_paths = HashSet::new();
419419
make_tests(c, &mut tests, &mut found_paths);
420420
check_overlapping_tests(&found_paths);
421421
}
@@ -550,7 +550,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
550550
pub fn make_tests(
551551
config: Arc<Config>,
552552
tests: &mut Vec<test::TestDescAndFn>,
553-
found_paths: &mut BTreeSet<PathBuf>,
553+
found_paths: &mut HashSet<PathBuf>,
554554
) {
555555
debug!("making tests from {:?}", config.src_base.display());
556556
let inputs = common_inputs_stamp(&config);
@@ -646,7 +646,7 @@ fn collect_tests_from_dir(
646646
relative_dir_path: &Path,
647647
inputs: &Stamp,
648648
tests: &mut Vec<test::TestDescAndFn>,
649-
found_paths: &mut BTreeSet<PathBuf>,
649+
found_paths: &mut HashSet<PathBuf>,
650650
modified_tests: &Vec<PathBuf>,
651651
poisoned: &mut bool,
652652
) -> io::Result<()> {
@@ -1128,7 +1128,7 @@ fn not_a_digit(c: char) -> bool {
11281128
!c.is_digit(10)
11291129
}
11301130

1131-
fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
1131+
fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) {
11321132
let mut collisions = Vec::new();
11331133
for path in found_paths {
11341134
for ancestor in path.ancestors().skip(1) {
@@ -1138,6 +1138,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
11381138
}
11391139
}
11401140
if !collisions.is_empty() {
1141+
collisions.sort();
11411142
let collisions: String = collisions
11421143
.into_iter()
11431144
.map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n"))

0 commit comments

Comments
 (0)