Skip to content

Commit

Permalink
refactor: Optimize code based on cargo clippy suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: InventiveCoder <liucongcong@outlook.com>
  • Loading branch information
InventiveCoder committed Mar 18, 2024
1 parent f36d6a7 commit 6ded2ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
25 changes: 13 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,17 @@ use std::sync::{Arc, Mutex};
#[cfg(feature = "parallel")]
mod parallel;
mod windows;

// Regardless of whether this should be in this crate's public API,
// it has been since 2015, so don't break it.
pub use windows::find_tools as windows_registry;

mod command_helpers;

use command_helpers::*;

mod tool;

pub use tool::Tool;
use tool::ToolFamily;

Expand Down Expand Up @@ -2060,14 +2063,11 @@ impl Build {
} else {
cmd.push_cc_arg(format!("--target={}", target).into());
}
} else {
if target.contains("i586") {
cmd.push_cc_arg("-arch:IA32".into());
} else if target.contains("arm64ec") {
cmd.push_cc_arg("-arm64EC".into());
}
} else if target.contains("i586") {
cmd.push_cc_arg("-arch:IA32".into());
} else if target.contains("arm64ec") {
cmd.push_cc_arg("-arm64EC".into());
}

// There is a check in corecrt.h that will generate a
// compilation error if
// _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is
Expand Down Expand Up @@ -3415,11 +3415,11 @@ impl Build {
})
.map(|prefix| *prefix)
.or_else(||
// If no toolchain was found, provide the first toolchain that was passed in.
// This toolchain has been shown not to exist, however it will appear in the
// error that is shown to the user which should make it easier to search for
// where it should be obtained.
prefixes.first().map(|prefix| *prefix))
// If no toolchain was found, provide the first toolchain that was passed in.
// This toolchain has been shown not to exist, however it will appear in the
// error that is shown to the user which should make it easier to search for
// where it should be obtained.
prefixes.first().map(|prefix| *prefix))
}

fn get_target(&self) -> Result<Arc<str>, Error> {
Expand Down Expand Up @@ -3753,6 +3753,7 @@ enum AppleOs {
WatchOs,
TvOs,
}

impl std::fmt::Debug for AppleOs {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down
6 changes: 2 additions & 4 deletions src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ impl Tool {
if chars.next() != Some('/') {
return false;
}
} else if self.is_like_gnu() || self.is_like_clang() {
if chars.next() != Some('-') {
return false;
}
} else if (self.is_like_gnu() || self.is_like_clang()) && chars.next() != Some('-') {
return false;
}

// Check for existing optimization flags (-O, /O)
Expand Down

0 comments on commit 6ded2ac

Please sign in to comment.