From 734ef0a8a1a27f4014b3e485bcba57d8301ae9a5 Mon Sep 17 00:00:00 2001 From: Mikadore Date: Wed, 10 Mar 2021 21:54:31 +0100 Subject: [PATCH] uniq: fixed #550 (#1790) --- src/uu/uniq/src/uniq.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index f636adde7..afbda2829 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -131,10 +131,7 @@ impl Uniq { // fast path: avoid skipping if self.ignore_case && slice_start == 0 && slice_stop == len { - return closure(&mut fields_to_check.chars().map(|c| match c { - 'a'..='z' => ((c as u8) - 32) as char, - _ => c, - })); + return closure(&mut fields_to_check.chars().flat_map(|c| c.to_uppercase())); } // fast path: we can avoid mapping chars to upper-case, if we don't want to ignore the case @@ -147,10 +144,7 @@ impl Uniq { .chars() .skip(slice_start) .take(slice_stop) - .map(|c| match c { - 'a'..='z' => ((c as u8) - 32) as char, - _ => c, - }), + .flat_map(|c| c.to_uppercase()), ) } else { closure(&mut fields_to_check.chars())