mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
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:
parent
c85798ddcf
commit
0717d8dd0a
@ -17,7 +17,7 @@ fn main() {
|
||||
|
||||
// Run actool to compile .icon to Assets.car
|
||||
let output = Command::new("xcrun")
|
||||
.args(&[
|
||||
.args([
|
||||
"actool",
|
||||
&icon_source,
|
||||
"--compile",
|
||||
|
||||
@ -175,7 +175,7 @@ impl ConstantTimeEqNull for [u8] {
|
||||
#[inline]
|
||||
fn ct_eq_null(&self) -> Choice {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ fn thumb_scale_filter_args(
|
||||
eprintln!("Warning: Failed to calculate width with pixel aspect ratio");
|
||||
// Keep the original width as fallback
|
||||
}
|
||||
};
|
||||
}
|
||||
if size != 0 {
|
||||
if height > width {
|
||||
width = (width * size) / height;
|
||||
|
||||
@ -92,7 +92,7 @@ impl FrameDecoder {
|
||||
})
|
||||
}
|
||||
|
||||
pub const fn use_embedded(&self) -> bool {
|
||||
#[must_use] pub const fn use_embedded(&self) -> bool {
|
||||
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| {
|
||||
let av_time_base = i64::from(AV_TIME_BASE);
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
|
||||
@ -110,22 +110,20 @@ impl EventFilters {
|
||||
let path_str = path.to_string_lossy();
|
||||
|
||||
// Check temp files
|
||||
if self.skip_temp_files {
|
||||
if path_str.contains(".tmp")
|
||||
if self.skip_temp_files
|
||||
&& (path_str.contains(".tmp")
|
||||
|| path_str.contains(".temp")
|
||||
|| path_str.ends_with("~")
|
||||
|| path_str.ends_with(".swp")
|
||||
|| path_str.ends_with(".swp"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check system files
|
||||
if self.skip_system_files {
|
||||
if path_str.contains(".DS_Store") || path_str.contains("Thumbs.db") {
|
||||
if self.skip_system_files
|
||||
&& (path_str.contains(".DS_Store") || path_str.contains("Thumbs.db")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check hidden files
|
||||
if self.skip_hidden {
|
||||
|
||||
@ -28,7 +28,7 @@ pub fn derive_job(input: TokenStream) -> TokenStream {
|
||||
let name = &input.ident;
|
||||
|
||||
// Ensure this is a struct
|
||||
let _data = match &input.data {
|
||||
match &input.data {
|
||||
Data::Struct(DataStruct { .. }) => {}
|
||||
_ => {
|
||||
return syn::Error::new_spanned(&input.ident, "Job can only be derived for structs")
|
||||
|
||||
@ -96,7 +96,7 @@ pub fn generate_phase_summary(analyzer: &LogAnalyzer, phase_duration_secs: u64)
|
||||
.join("::");
|
||||
by_module
|
||||
.entry(module_base)
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push((template_id, count));
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ fn build_ios() -> Result<()> {
|
||||
println!("Building for iOS {} ({})...", platform, arch);
|
||||
|
||||
let status = Command::new("cargo")
|
||||
.args(&["build", "--release", "--target", target])
|
||||
.args(["build", "--release", "--target", target])
|
||||
.current_dir(&ios_core_dir)
|
||||
.env("IPHONEOS_DEPLOYMENT_TARGET", "12.0")
|
||||
.status()
|
||||
@ -284,7 +284,7 @@ fn build_ios() -> Result<()> {
|
||||
// Create universal simulator library using lipo
|
||||
println!("Creating universal simulator library...");
|
||||
let status = Command::new("lipo")
|
||||
.args(&[
|
||||
.args([
|
||||
"-create",
|
||||
ios_core_dir
|
||||
.join(format!(
|
||||
|
||||
@ -99,7 +99,7 @@ fn detect_libc() -> Result<Libc> {
|
||||
/// Get list of installed Rust targets
|
||||
pub fn get_rust_targets() -> Result<Vec<String>> {
|
||||
let output = Command::new("rustup")
|
||||
.args(&["target", "list", "--installed"])
|
||||
.args(["target", "list", "--installed"])
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
@ -129,10 +129,9 @@ pub fn get_best_linker() -> Option<String> {
|
||||
return Some("lld".to_string());
|
||||
}
|
||||
}
|
||||
} else if cfg!(target_os = "windows") {
|
||||
if has_linker("lld-link") {
|
||||
} else if cfg!(target_os = "windows")
|
||||
&& has_linker("lld-link") {
|
||||
return Some("lld-link".to_string());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user