diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index 4207b3c776c..d6fcff644ac 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -122,6 +122,9 @@ pub fn is_digit(self, radix: u32) -> bool { #[inline] pub fn to_digit(self, radix: u32) -> Option { assert!(radix <= 36, "to_digit: radix is too high (maximum 36)"); + + // the code is split up here to improve execution speed for cases where + // the `radix` is constant and 10 or smaller let val = if radix <= 10 { match self { '0' ..= '9' => self as u32 - '0' as u32,