diff options
| author | bors <bors@rust-lang.org> | 2020-02-12 16:25:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-12 16:25:13 +0000 |
| commit | 2d2be570970d784db5539a1d309cd22b85be910a (patch) | |
| tree | 52c9407b54a2b5c06af608699528a311406a4e78 /src/libcore | |
| parent | 2ed25f069768c046464e68fd382c867ddb04a1e3 (diff) | |
| parent | d9982f1f817e67149316b60fbacb0425e7179365 (diff) | |
| download | rust-2d2be570970d784db5539a1d309cd22b85be910a.tar.gz rust-2d2be570970d784db5539a1d309cd22b85be910a.zip | |
Auto merge of #69094 - Dylan-DPC:rollup-4qe7uv1, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #67585 (Improve `char::is_ascii_*` codegen) - #68914 (Speed up `SipHasher128`.) - #68994 (rustbuild: include channel in sanitizers installed name) - #69032 (ICE in nightly-2020-02-08: handle TerminatorKind::Yield in librustc_mir::transform::promote_consts::Validator method) - #69034 (parser: Remove `Parser::prev_token_kind`) - #69042 (Remove backtrace header text) - #69059 (Remove a few unused objects) - #69089 (Properly use the darwin archive format on Apple targets) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/char/methods.rs | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index 2b52c48cb90..302400744e2 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -1075,7 +1075,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_alphabetic(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_alphabetic() + match *self { + 'A'..='Z' | 'a'..='z' => true, + _ => false, + } } /// Checks if the value is an ASCII uppercase character: @@ -1108,7 +1111,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_uppercase(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_uppercase() + match *self { + 'A'..='Z' => true, + _ => false, + } } /// Checks if the value is an ASCII lowercase character: @@ -1141,7 +1147,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_lowercase(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_lowercase() + match *self { + 'a'..='z' => true, + _ => false, + } } /// Checks if the value is an ASCII alphanumeric character: @@ -1177,7 +1186,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_alphanumeric(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_alphanumeric() + match *self { + '0'..='9' | 'A'..='Z' | 'a'..='z' => true, + _ => false, + } } /// Checks if the value is an ASCII decimal digit: @@ -1210,7 +1222,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_digit(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_digit() + match *self { + '0'..='9' => true, + _ => false, + } } /// Checks if the value is an ASCII hexadecimal digit: @@ -1246,7 +1261,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_hexdigit(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_hexdigit() + match *self { + '0'..='9' | 'A'..='F' | 'a'..='f' => true, + _ => false, + } } /// Checks if the value is an ASCII punctuation character: @@ -1283,7 +1301,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_punctuation(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_punctuation() + match *self { + '!'..='/' | ':'..='@' | '['..='`' | '{'..='~' => true, + _ => false, + } } /// Checks if the value is an ASCII graphic character: @@ -1316,7 +1337,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_graphic(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_graphic() + match *self { + '!'..='~' => true, + _ => false, + } } /// Checks if the value is an ASCII whitespace character: @@ -1366,7 +1390,10 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_whitespace(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_whitespace() + match *self { + '\t' | '\n' | '\x0C' | '\r' | ' ' => true, + _ => false, + } } /// Checks if the value is an ASCII control character: @@ -1401,6 +1428,9 @@ impl char { #[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")] #[inline] pub const fn is_ascii_control(&self) -> bool { - self.is_ascii() && (*self as u8).is_ascii_control() + match *self { + '\0'..='\x1F' | '\x7F' => true, + _ => false, + } } } |
