From 224be498afc64fc46cd367aa4e51e23dc66de7ca Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 8 Jan 2026 14:28:54 +0100 Subject: [PATCH] ls: remove redundant HashMap lookup in append_raw_style_code_for_indicator --- src/uu/ls/src/colors.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/uu/ls/src/colors.rs b/src/uu/ls/src/colors.rs index 8eb4b7097..fc481eab0 100644 --- a/src/uu/ls/src/colors.rs +++ b/src/uu/ls/src/colors.rs @@ -129,14 +129,11 @@ impl<'a> StyleManager<'a> { indicator: Indicator, style_code: &mut String, ) { - if !self.indicator_codes.contains_key(&indicator) { - return; - } - style_code.push_str(self.reset(!self.initial_reset_is_done)); - style_code.push_str(ANSI_CSI); - if let Some(raw) = self.indicator_codes.get(&indicator) { + if let Some(raw) = self.indicator_codes.get(&indicator).cloned() { debug_assert!(!raw.is_empty()); - style_code.push_str(raw); + style_code.push_str(self.reset(!self.initial_reset_is_done)); + style_code.push_str(ANSI_CSI); + style_code.push_str(&raw); style_code.push_str(ANSI_SGR_END); } }