Conversation
|
GNU testsuite comparison: |
Merging this PR will improve performance by 3.44%
Performance Changes
Comparing Footnotes
|
| let term_str = term.as_deref().unwrap_or_default().to_string_lossy(); | ||
| let colorterm_str = colorterm.as_deref().unwrap_or_default().to_string_lossy(); | ||
|
|
||
| if term.is_some() && term_str.is_empty() && colorterm.is_some() && colorterm_str.is_empty() { |
There was a problem hiding this comment.
While the changes to this function are an improvement, I think using a match would be cleaner. Something like:
match (term, colorterm) {
(Some(t), Some(c)) if t.is_empty() && c.is_empty() => false,
(Some(t), _) if !t.is_empty() => term_matches(&t.to_string_lossy()),
_ => true,
}Please note that the semantics of the third line are slightly different than those of the original code. I don't know if that's an issue.
|
|
||
| fn calculate_line_len(output_len: usize, item_len: usize, line_ending: LineEnding) -> usize { | ||
| output_len + item_len + line_ending.to_string().len() | ||
| fn calculate_line_len(output_len: usize, item_len: usize, _line_ending: LineEnding) -> usize { |
There was a problem hiding this comment.
I would remove either the _line_ending param to simplify the function signature. Or the entire function. The function is called in a single place and so the (trivial) calculation could be done there.
Both approaches also allow you to simplify the signature of update_dired_for_item.
| canonical.push_str(value); | ||
| Cow::Owned(canonical) | ||
| if value.len() == 1 && value.as_bytes()[0].is_ascii_digit() { | ||
| Cow::Owned(format!("0{value}")) |
There was a problem hiding this comment.
My hunch is that the manual string construction is faster than format -- but I haven't benchmarked stuff for a while now, maybe format improved...
Not sure how much you care about performance in this case (didn't look at callers)
| .unwrap() | ||
| .eq("human-readable")) | ||
| let opt_si = | ||
| opt_block_size.is_some_and(|v| v == "si") || options.get_flag(options::size::SI); |
There was a problem hiding this comment.
Does this work? opt_block_size == Some("si") (I think so)
No description provided.