diff --git a/src/uu/sort/src/external_sort/mod.rs b/src/uu/sort/src/external_sort/mod.rs index 81455eb18..fd942d4a7 100644 --- a/src/uu/sort/src/external_sort/mod.rs +++ b/src/uu/sort/src/external_sort/mod.rs @@ -183,16 +183,16 @@ where let seq_size = seq.get_size(); total_read += seq_size; - // GNU minimum is 16 * (sizeof struct + 2), but GNU uses about - // 1/10 the memory that we do. And GNU even says in the code it may + // GNU minimum is 16 * (sizeof struct + 2), but GNU uses about + // 1/10 the memory that we do. And GNU even says in the code it may // not work on small buffer sizes. - // - // The following seems to work pretty well, and has about the same max + // + // The following seems to work pretty well, and has about the same max // RSS as lower minimum values. - // + // let minimum_buffer_size: u64 = iter_size as u64 * seq_size / 8; - - adjusted_buffer_size = + + adjusted_buffer_size = // Grow buffer size for a struct/Line larger than buffer if adjusted_buffer_size < seq_size { seq_size @@ -233,14 +233,13 @@ where // const MINIMUM_READBACK_BUFFER: u64 = 8200; let right_sized_buffer = adjusted_buffer_size - .checked_div(iter.chunks) - .unwrap_or(adjusted_buffer_size); - iter.max_per_chunk = - if right_sized_buffer > MINIMUM_READBACK_BUFFER { - right_sized_buffer - } else { - MINIMUM_READBACK_BUFFER - }; + .checked_div(iter.chunks) + .unwrap_or(adjusted_buffer_size); + iter.max_per_chunk = if right_sized_buffer > MINIMUM_READBACK_BUFFER { + right_sized_buffer + } else { + MINIMUM_READBACK_BUFFER + }; iter.buffers = vec![VecDeque::new(); iter.chunks as usize]; iter.chunk_offsets = vec![0 as u64; iter.chunks as usize]; for chunk_num in 0..iter.chunks { diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 53f9a356a..c9e797579 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -92,17 +92,12 @@ static THOUSANDS_SEP: char = ','; static NEGATIVE: char = '-'; static POSITIVE: char = '+'; -#[cfg(any( - target_os = "windows", -))] +#[cfg(any(target_os = "windows",))] static DEFAULT_TMPDIR: &str = r"%USERPROFILE%\AppData\Local\Temp"; -#[cfg(not(any( - target_os = "windows", -)))] +#[cfg(not(any(target_os = "windows",)))] static DEFAULT_TMPDIR: &str = r"/tmp"; - static DEFAULT_BUF_SIZE: usize = usize::MAX; #[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Copy)] @@ -1073,9 +1068,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.tmp_dir = PathBuf::from(result); } else { for (key, value) in env::vars_os() { - if key == OsString::from("TMPDIR") - || key == OsString::from("TEMP") - || key == OsString::from("TMP") + if key == OsString::from("TMPDIR") + || key == OsString::from("TEMP") + || key == OsString::from("TMP") { settings.tmp_dir = PathBuf::from(value); break; @@ -1311,11 +1306,10 @@ fn compare_by(a: &Line, b: &Line, global_settings: &GlobalSettings) -> Ordering (a_str, a_selection.num_cache.as_num_info()), (b_str, b_selection.num_cache.as_num_info()), ), - SortMode::GeneralNumeric => { - general_numeric_compare( - general_f64_parse(&a_str[get_leading_gen(a_str)]), - general_f64_parse(&b_str[get_leading_gen(b_str)]),) - } + SortMode::GeneralNumeric => general_numeric_compare( + general_f64_parse(&a_str[get_leading_gen(a_str)]), + general_f64_parse(&b_str[get_leading_gen(b_str)]), + ), SortMode::Month => month_compare(a_str, b_str), SortMode::Version => version_compare(a_str, b_str), SortMode::Default => default_compare(a_str, b_str),