Skip to content

Commit

Permalink
Return early to avoid excessive indentation.`
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Oct 10, 2016
1 parent a8e2570 commit 7c7a594
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/librustc/session/filesearch.rs
Expand Up @@ -68,33 +68,32 @@ impl<'a> FileSearch<'a> {
{
self.for_each_lib_search_path(|lib_search_path, kind| {
debug!("searching {}", lib_search_path.display());
match fs::read_dir(lib_search_path) {
Ok(files) => {
let files = files.filter_map(|p| p.ok().map(|s| s.path()))
.collect::<Vec<_>>();
fn is_rlib(p: &Path) -> bool {
p.extension().and_then(|s| s.to_str()) == Some("rlib")
let files = match fs::read_dir(lib_search_path) {
Ok(files) => files,
Err(..) => return,
};
let files = files.filter_map(|p| p.ok().map(|s| s.path()))
.collect::<Vec<_>>();
fn is_rlib(p: &Path) -> bool {
p.extension().and_then(|s| s.to_str()) == Some("rlib")
}
// Reading metadata out of rlibs is faster, and if we find both
// an rlib and a dylib we only read one of the files of
// metadata, so in the name of speed, bring all rlib files to
// the front of the search list.
let files1 = files.iter().filter(|p| is_rlib(p));
let files2 = files.iter().filter(|p| !is_rlib(p));
for path in files1.chain(files2) {
debug!("testing {}", path.display());
let maybe_picked = pick(path, kind);
match maybe_picked {
FileMatches => {
debug!("picked {}", path.display());
}
// Reading metadata out of rlibs is faster, and if we find both
// an rlib and a dylib we only read one of the files of
// metadata, so in the name of speed, bring all rlib files to
// the front of the search list.
let files1 = files.iter().filter(|p| is_rlib(p));
let files2 = files.iter().filter(|p| !is_rlib(p));
for path in files1.chain(files2) {
debug!("testing {}", path.display());
let maybe_picked = pick(path, kind);
match maybe_picked {
FileMatches => {
debug!("picked {}", path.display());
}
FileDoesntMatch => {
debug!("rejected {}", path.display());
}
}
FileDoesntMatch => {
debug!("rejected {}", path.display());
}
}
Err(..) => (),
}
});
}
Expand Down

0 comments on commit 7c7a594

Please sign in to comment.