Skip to content

Commit 18be4ff

Browse files
Extend ASCII fast paths of char methods beyond ASCII
1 parent 58dcd1f commit 18be4ff

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

library/core/src/char/methods.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,9 @@ impl char {
742742
#[inline]
743743
pub fn is_alphabetic(self) -> bool {
744744
match self {
745-
'a'..='z' | 'A'..='Z' => true,
746-
c => c > '\x7f' && unicode::Alphabetic(c),
745+
'A'..='Z' | 'a'..='z' => true,
746+
'\0'..='\u{A9}' => false,
747+
_ => unicode::Alphabetic(self),
747748
}
748749
}
749750

@@ -785,7 +786,8 @@ impl char {
785786
pub const fn is_lowercase(self) -> bool {
786787
match self {
787788
'a'..='z' => true,
788-
c => c > '\x7f' && unicode::Lowercase(c),
789+
'\0'..='\u{A9}' => false,
790+
_ => unicode::Lowercase(self),
789791
}
790792
}
791793

@@ -827,7 +829,8 @@ impl char {
827829
pub const fn is_uppercase(self) -> bool {
828830
match self {
829831
'A'..='Z' => true,
830-
c => c > '\x7f' && unicode::Uppercase(c),
832+
'\0'..='\u{BF}' => false,
833+
_ => unicode::Uppercase(self),
831834
}
832835
}
833836

@@ -859,7 +862,8 @@ impl char {
859862
pub fn is_whitespace(self) -> bool {
860863
match self {
861864
' ' | '\x09'..='\x0d' => true,
862-
c => c > '\x7f' && unicode::White_Space(c),
865+
'\0'..='\u{84}' => false,
866+
_ => unicode::White_Space(self),
863867
}
864868
}
865869

@@ -927,7 +931,7 @@ impl char {
927931
#[must_use]
928932
#[inline]
929933
pub(crate) fn is_grapheme_extended(self) -> bool {
930-
self > '\x7f' && unicode::Grapheme_Extend(self)
934+
self > '\u{02FF}' && unicode::Grapheme_Extend(self)
931935
}
932936

933937
/// Returns `true` if this `char` has one of the general categories for numbers.
@@ -969,7 +973,8 @@ impl char {
969973
pub fn is_numeric(self) -> bool {
970974
match self {
971975
'0'..='9' => true,
972-
c => c > '\x7f' && unicode::N(c),
976+
'\0'..='\u{B1}' => false,
977+
_ => unicode::N(self),
973978
}
974979
}
975980

0 commit comments

Comments
 (0)