Refactor code for improved clarity and performance

- Updated argument passing in various commands to use a more concise syntax.
- Simplified iteration in the ConstantTimeEqNull implementation for better readability.
- Enhanced file path checks in EventFilters for temporary and system files.
- Added `#[must_use]` attribute to functions in FrameDecoder to indicate their importance.
- Replaced `or_insert_with` with `or_default` for cleaner code in phase summary generation.
This commit is contained in:
Jamie Pine 2025-12-10 14:43:17 -08:00
parent c85798ddcf
commit 0717d8dd0a
9 changed files with 17 additions and 20 deletions

View File

@ -17,7 +17,7 @@ fn main() {
// Run actool to compile .icon to Assets.car // Run actool to compile .icon to Assets.car
let output = Command::new("xcrun") let output = Command::new("xcrun")
.args(&[ .args([
"actool", "actool",
&icon_source, &icon_source,
"--compile", "--compile",

View File

@ -175,7 +175,7 @@ impl ConstantTimeEqNull for [u8] {
#[inline] #[inline]
fn ct_eq_null(&self) -> Choice { fn ct_eq_null(&self) -> Choice {
let mut x = 1u8; let mut x = 1u8;
self.iter().for_each(|b| b.cmovne(&0, 0u8, &mut x)); for b in self.iter() { b.cmovne(&0, 0u8, &mut x); }
Choice::from(x) Choice::from(x)
} }
} }

View File

@ -241,7 +241,7 @@ fn thumb_scale_filter_args(
eprintln!("Warning: Failed to calculate width with pixel aspect ratio"); eprintln!("Warning: Failed to calculate width with pixel aspect ratio");
// Keep the original width as fallback // Keep the original width as fallback
} }
}; }
if size != 0 { if size != 0 {
if height > width { if height > width {
width = (width * size) / height; width = (width * size) / height;

View File

@ -92,7 +92,7 @@ impl FrameDecoder {
}) })
} }
pub const fn use_embedded(&self) -> bool { #[must_use] pub const fn use_embedded(&self) -> bool {
self.embedded self.embedded
} }
@ -224,7 +224,7 @@ impl FrameDecoder {
}) })
} }
pub fn get_duration_secs(&self) -> Option<f64> { #[must_use] pub fn get_duration_secs(&self) -> Option<f64> {
self.format_ctx.duration().map(|duration| { self.format_ctx.duration().map(|duration| {
let av_time_base = i64::from(AV_TIME_BASE); let av_time_base = i64::from(AV_TIME_BASE);
#[allow(clippy::cast_precision_loss)] #[allow(clippy::cast_precision_loss)]

View File

@ -110,22 +110,20 @@ impl EventFilters {
let path_str = path.to_string_lossy(); let path_str = path.to_string_lossy();
// Check temp files // Check temp files
if self.skip_temp_files { if self.skip_temp_files
if path_str.contains(".tmp") && (path_str.contains(".tmp")
|| path_str.contains(".temp") || path_str.contains(".temp")
|| path_str.ends_with("~") || path_str.ends_with("~")
|| path_str.ends_with(".swp") || path_str.ends_with(".swp"))
{ {
return true; return true;
} }
}
// Check system files // Check system files
if self.skip_system_files { if self.skip_system_files
if path_str.contains(".DS_Store") || path_str.contains("Thumbs.db") { && (path_str.contains(".DS_Store") || path_str.contains("Thumbs.db")) {
return true; return true;
} }
}
// Check hidden files // Check hidden files
if self.skip_hidden { if self.skip_hidden {

View File

@ -28,7 +28,7 @@ pub fn derive_job(input: TokenStream) -> TokenStream {
let name = &input.ident; let name = &input.ident;
// Ensure this is a struct // Ensure this is a struct
let _data = match &input.data { match &input.data {
Data::Struct(DataStruct { .. }) => {} Data::Struct(DataStruct { .. }) => {}
_ => { _ => {
return syn::Error::new_spanned(&input.ident, "Job can only be derived for structs") return syn::Error::new_spanned(&input.ident, "Job can only be derived for structs")

View File

@ -96,7 +96,7 @@ pub fn generate_phase_summary(analyzer: &LogAnalyzer, phase_duration_secs: u64)
.join("::"); .join("::");
by_module by_module
.entry(module_base) .entry(module_base)
.or_insert_with(Vec::new) .or_default()
.push((template_id, count)); .push((template_id, count));
} }

View File

@ -239,7 +239,7 @@ fn build_ios() -> Result<()> {
println!("Building for iOS {} ({})...", platform, arch); println!("Building for iOS {} ({})...", platform, arch);
let status = Command::new("cargo") let status = Command::new("cargo")
.args(&["build", "--release", "--target", target]) .args(["build", "--release", "--target", target])
.current_dir(&ios_core_dir) .current_dir(&ios_core_dir)
.env("IPHONEOS_DEPLOYMENT_TARGET", "12.0") .env("IPHONEOS_DEPLOYMENT_TARGET", "12.0")
.status() .status()
@ -284,7 +284,7 @@ fn build_ios() -> Result<()> {
// Create universal simulator library using lipo // Create universal simulator library using lipo
println!("Creating universal simulator library..."); println!("Creating universal simulator library...");
let status = Command::new("lipo") let status = Command::new("lipo")
.args(&[ .args([
"-create", "-create",
ios_core_dir ios_core_dir
.join(format!( .join(format!(

View File

@ -99,7 +99,7 @@ fn detect_libc() -> Result<Libc> {
/// Get list of installed Rust targets /// Get list of installed Rust targets
pub fn get_rust_targets() -> Result<Vec<String>> { pub fn get_rust_targets() -> Result<Vec<String>> {
let output = Command::new("rustup") let output = Command::new("rustup")
.args(&["target", "list", "--installed"]) .args(["target", "list", "--installed"])
.output()?; .output()?;
if !output.status.success() { if !output.status.success() {
@ -129,10 +129,9 @@ pub fn get_best_linker() -> Option<String> {
return Some("lld".to_string()); return Some("lld".to_string());
} }
} }
} else if cfg!(target_os = "windows") { } else if cfg!(target_os = "windows")
if has_linker("lld-link") { && has_linker("lld-link") {
return Some("lld-link".to_string()); return Some("lld-link".to_string());
} }
}
None None
} }