File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1544,9 +1544,18 @@ impl char {
1544
1544
#[ rustc_const_stable( feature = "const_ascii_ctype_on_intrinsics" , since = "1.47.0" ) ]
1545
1545
#[ inline]
1546
1546
pub const fn is_ascii_whitespace ( & self ) -> bool {
1547
- match * self {
1548
- '\t' | '\n' | '\x0C' | '\r' | ' ' => true ,
1549
- _ => false ,
1547
+ #[ cfg( target_pointer_width = "64" ) ]
1548
+ {
1549
+ // 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
+ }
1550
1559
}
1551
1560
}
1552
1561
You can’t perform that action at this time.
0 commit comments