We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0bf356 commit 82ff02bCopy full SHA for 82ff02b
library/core/src/char/methods.rs
@@ -1544,9 +1544,18 @@ impl char {
1544
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
1545
#[inline]
1546
pub const fn is_ascii_whitespace(&self) -> bool {
1547
- match *self {
1548
- '\t' | '\n' | '\x0C' | '\r' | ' ' => true,
1549
- _ => false,
+ #[cfg(target_pointer_width = "64")]
+ {
+ // Inspired from https://pdimov.github.io/blog/2020/07/19/llvm-and-memchr/
1550
+ const MASK: u64 = 1 << b'\t' | 1 << b'\n' | 1 << b'\x0C' | 1 << b'\r' | 1 << b' ';
1551
+ *self <= ' ' && 1u64 << (*self as u8) & MASK != 0
1552
+ }
1553
+ #[cfg(not(target_pointer_width = "64"))]
1554
1555
+ match *self {
1556
+ '\t' | '\n' | '\x0C' | '\r' | ' ' => true,
1557
+ _ => false,
1558
1559
}
1560
1561
0 commit comments