File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,13 @@ fn bench_to_digit_radix_var(b: &mut Bencher) {
35
35
. min ( )
36
36
} )
37
37
}
38
+
39
+ #[ bench]
40
+ fn bench_to_ascii_uppercase ( b : & mut Bencher ) {
41
+ b. iter ( || CHARS . iter ( ) . cycle ( ) . take ( 10_000 ) . map ( |c| c. to_ascii_uppercase ( ) ) . min ( ) )
42
+ }
43
+
44
+ #[ bench]
45
+ fn bench_to_ascii_lowercase ( b : & mut Bencher ) {
46
+ b. iter ( || CHARS . iter ( ) . cycle ( ) . take ( 10_000 ) . map ( |c| c. to_ascii_lowercase ( ) ) . min ( ) )
47
+ }
Original file line number Diff line number Diff line change @@ -1090,7 +1090,8 @@ impl char {
1090
1090
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1091
1091
#[ inline]
1092
1092
pub fn to_ascii_uppercase ( & self ) -> char {
1093
- if self . is_ascii ( ) { ( * self as u8 ) . to_ascii_uppercase ( ) as char } else { * self }
1093
+ // 6th bit dictates ascii case.
1094
+ if self . is_ascii_lowercase ( ) { ( ( * self as u8 ) & !0b10_0000u8 ) as char } else { * self }
1094
1095
}
1095
1096
1096
1097
/// Makes a copy of the value in its ASCII lower case equivalent.
@@ -1118,7 +1119,8 @@ impl char {
1118
1119
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1119
1120
#[ inline]
1120
1121
pub fn to_ascii_lowercase ( & self ) -> char {
1121
- if self . is_ascii ( ) { ( * self as u8 ) . to_ascii_lowercase ( ) as char } else { * self }
1122
+ // 6th bit dictates ascii case.
1123
+ if self . is_ascii_uppercase ( ) { ( ( * self as u8 ) | 0b10_0000u8 ) as char } else { * self }
1122
1124
}
1123
1125
1124
1126
/// Checks that two values are an ASCII case-insensitive match.
You can’t perform that action at this time.
0 commit comments