1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

uniq: fixed #550 (#1790)

This commit is contained in:
Mikadore 2021-03-10 21:54:31 +01:00 committed by GitHub
parent a42e24e088
commit 734ef0a8a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,10 +131,7 @@ impl Uniq {
// fast path: avoid skipping // fast path: avoid skipping
if self.ignore_case && slice_start == 0 && slice_stop == len { if self.ignore_case && slice_start == 0 && slice_stop == len {
return closure(&mut fields_to_check.chars().map(|c| match c { return closure(&mut fields_to_check.chars().flat_map(|c| c.to_uppercase()));
'a'..='z' => ((c as u8) - 32) as char,
_ => c,
}));
} }
// fast path: we can avoid mapping chars to upper-case, if we don't want to ignore the case // 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() .chars()
.skip(slice_start) .skip(slice_start)
.take(slice_stop) .take(slice_stop)
.map(|c| match c { .flat_map(|c| c.to_uppercase()),
'a'..='z' => ((c as u8) - 32) as char,
_ => c,
}),
) )
} else { } else {
closure(&mut fields_to_check.chars()) closure(&mut fields_to_check.chars())