Skip to content

Commit a5204c4

Browse files
fdncredsylvestre
authored andcommitted
tweak perf
1 parent 6781aa2 commit a5204c4

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/uu/ls/src/ls.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,14 +1093,12 @@ impl LsOutput for TextOutput<'_> {
10931093
if config.dired {
10941094
dired::indent(&mut self.state.out)?;
10951095
}
1096-
let total_str = format!(
1097-
"{}{}",
1098-
translate!("ls-total", "size" => display_size(total_size, config)),
1099-
config.line_ending
1100-
);
1101-
write!(self.state.out, "{total_str}")?;
1096+
let total = translate!("ls-total", "size" => display_size(total_size, config));
1097+
let total_len = total.len() + 1;
1098+
self.state.out.write_all(total.as_bytes())?;
1099+
self.state.out.write_all(&[config.line_ending as u8])?;
11021100
if config.dired {
1103-
dired::add_total(&mut self.dired, total_str.len());
1101+
dired::add_total(&mut self.dired, total_len);
11041102
}
11051103
Ok(())
11061104
}
@@ -1296,9 +1294,7 @@ fn collect_directory_entries<O: LsOutput>(
12961294
}
12971295

12981296
sort_entries(entries, config);
1299-
if entries.capacity() > entries.len().saturating_mul(2) {
1300-
entries.shrink_to_fit();
1301-
}
1297+
entries.shrink_to_fit();
13021298

13031299
Ok(())
13041300
}

0 commit comments

Comments
 (0)