Skip to content

Commit abb52b2

Browse files
committed
ls: simplify canonicalize_indicator_value
1 parent feec448 commit abb52b2

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/uu/ls/src/colors.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,8 @@ fn parse_indicator_codes() -> (FxHashMap<Indicator, String>, bool) {
786786
}
787787

788788
fn canonicalize_indicator_value(value: &str) -> Cow<'_, str> {
789-
if value.len() == 1 && value.chars().all(|c| c.is_ascii_digit()) {
790-
let mut canonical = String::with_capacity(2);
791-
canonical.push('0');
792-
canonical.push_str(value);
793-
Cow::Owned(canonical)
789+
if value.len() == 1 && value.as_bytes()[0].is_ascii_digit() {
790+
Cow::Owned(format!("0{value}"))
794791
} else {
795792
Cow::Borrowed(value)
796793
}

0 commit comments

Comments
 (0)