Reduce again the number of match calls (#7815)

- Reduce the number of match calls (see commit messages)
- A few miscellaneous improvements
This commit is contained in:
Hofer-Julian
2023-01-24 12:23:42 +01:00
committed by GitHub
parent 0bb2e47c98
commit 41306aa7e0
49 changed files with 467 additions and 634 deletions

View File

@@ -160,10 +160,7 @@ where
return Ok(());
}
let amount = match cfg.length {
Some(len) => len,
None => source.as_ref().len(),
};
let amount = cfg.length.unwrap_or_else(|| source.as_ref().len());
let skip = cfg.skip.unwrap_or(0);
@@ -239,10 +236,7 @@ where
write!(writer, " ")?;
for x in row {
let (style, a_char) = categorize_byte(x);
let replacement_char = match a_char {
Some(c) => c,
None => *x as char,
};
let replacement_char = a_char.unwrap_or(*x as char);
if use_color {
write!(
writer,