core/char: Drop radix == 10 special case

This seems to perform equally well
This commit is contained in:
Tobias Bieniek 2018-11-14 08:55:53 +01:00
parent 17f08fecfd
commit 64a5172652

View File

@ -122,14 +122,7 @@ impl char {
#[inline]
pub fn to_digit(self, radix: u32) -> Option<u32> {
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
if radix == 10 {
return match self {
'0' ..= '9' => Some(self as u32 - '0' as u32),
_ => None,
};
}
let val = if radix < 10 {
let val = if radix <= 10 {
match self {
'0' ..= '9' => self as u32 - '0' as u32,
_ => return None,