mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-02 19:32:25 +01:00
Fix clippy suggestions
Leads to a performance improvement for `bat -A`: | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `./bat-master --no-config -A ./bat-master` | 259.8 ± 1.1 | 258.4 | 261.7 | 1.15 ± 0.01 | | `./bat-2301 --no-config -A ./bat-master` | 225.6 ± 1.8 | 224.0 | 229.5 | 1.00 |
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::fmt::Write;
|
||||
|
||||
/// Expand tabs like an ANSI-enabled expand(1).
|
||||
pub fn expand_tabs(mut text: &str, width: usize, cursor: &mut usize) -> String {
|
||||
let mut buffer = String::with_capacity(text.len() * 2);
|
||||
@@ -92,7 +94,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
|
||||
c => output.push_str(&c.escape_unicode().collect::<String>()),
|
||||
}
|
||||
} else {
|
||||
output.push_str(&format!("\\x{:02X}", input[idx]));
|
||||
write!(output, "\\x{:02X}", input[idx]).ok();
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user