Skip to content

Commit f5b8097

Browse files
authored
Unrolled build for #145027
Rollup merge of #145027 - Kmeakin:km/optimize-char-is-alphanumeric, r=scottmcm Optimize `char::is_alphanumeric` Avoid an unnecessary call to `unicode::Alphabetic` when `self` is an ASCII digit (ie `0..=9`).
2 parents 2de2456 + bf50209 commit f5b8097

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/core/src/char/methods.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,11 @@ impl char {
920920
#[stable(feature = "rust1", since = "1.0.0")]
921921
#[inline]
922922
pub fn is_alphanumeric(self) -> bool {
923-
self.is_alphabetic() || self.is_numeric()
923+
if self.is_ascii() {
924+
self.is_ascii_alphanumeric()
925+
} else {
926+
unicode::Alphabetic(self) || unicode::N(self)
927+
}
924928
}
925929

926930
/// Returns `true` if this `char` has the general category for control codes.

0 commit comments

Comments
 (0)