We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
to_digit()
1 parent 64a5172 commit 7843e27Copy full SHA for 7843e27
src/libcore/char/methods.rs
@@ -122,6 +122,9 @@ impl char {
122
#[inline]
123
pub fn to_digit(self, radix: u32) -> Option<u32> {
124
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
125
+
126
+ // the code is split up here to improve execution speed for cases where
127
+ // the `radix` is constant and 10 or smaller
128
let val = if radix <= 10 {
129
match self {
130
'0' ..= '9' => self as u32 - '0' as u32,
0 commit comments