Skip to content

Commit 7843e27

Browse files
committed
core/char: Add comment to to_digit()
1 parent 64a5172 commit 7843e27

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: src/libcore/char/methods.rs

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ impl char {
122122
#[inline]
123123
pub fn to_digit(self, radix: u32) -> Option<u32> {
124124
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
125128
let val = if radix <= 10 {
126129
match self {
127130
'0' ..= '9' => self as u32 - '0' as u32,

0 commit comments

Comments
 (0)