diff --git a/.mailmap b/.mailmap index fa0728bd79461..69b12834b4bf0 100644 --- a/.mailmap +++ b/.mailmap @@ -160,7 +160,8 @@ Kyle J Strand Kyle J Strand Kyle J Strand Kyle J Strand -Laurențiu Nicola +Laurențiu Nicola Laurentiu Nicola +Laurențiu Nicola Lee Jeffery Lee Jeffery Lee Wondong Lennart Kudling diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 2603ecf428c7d..e83669cc476b8 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -1544,9 +1544,23 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_whitespace(&self) -> bool { - match *self { - '\t' | '\n' | '\x0C' | '\r' | ' ' => true, - _ => false, + #[cfg(not(target_pointer_width = "16"))] + { + // Inspired from https://pdimov.github.io/blog/2020/07/19/llvm-and-memchr/ + const MASK: u32 = 1 << (b'\t' - 1) + | 1 << (b'\n' - 1) + | 1 << (b'\x0C' - 1) + | 1 << (b'\r' - 1) + | 1 << (b' ' - 1); + let ch = (*self as u32).wrapping_sub(1); + ch < (' ' as u32) && 1 << (ch as u8) & MASK != 0 + } + #[cfg(target_pointer_width = "16")] + { + match *self { + '\t' | '\n' | '\x0C' | '\r' | ' ' => true, + _ => false, + } } }