Skip to content

Commit

Permalink
Minor optimize is_object
Browse files Browse the repository at this point in the history
Avoid metadata check for windows targets in some cases.
  • Loading branch information
taiki-e committed Feb 23, 2025
1 parent 3df8c10 commit b29dcba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,21 @@ fn object_files(cx: &Context) -> Result<Vec<OsString>> {
if ext == "d" || ext == "rlib" || ext == "rmeta" || f.ends_with(".cargo-lock") {
return false;
}
let target_is_windows = cx.ws.target_for_config.triple().contains("-windows");
if target_is_windows
&& !(ext.eq_ignore_ascii_case("exe") || ext.eq_ignore_ascii_case("dll"))
{
return false;
}
#[allow(clippy::disallowed_methods)] // std::fs is okay here since we ignore error contents
let Ok(metadata) = std::fs::metadata(f) else {
return false;
};
if !metadata.is_file() {
return false;
}
if cx.ws.target_for_config.triple().contains("-windows") {
ext.eq_ignore_ascii_case("exe") || ext.eq_ignore_ascii_case("dll")
if target_is_windows {
true
} else {
#[cfg(unix)]
{
Expand Down

0 comments on commit b29dcba

Please # to comment.