提交 64a51726 编写于 作者: T Tobias Bieniek

core/char: Drop `radix == 10` special case

This seems to perform equally well
上级 17f08fec
...@@ -122,14 +122,7 @@ pub fn is_digit(self, radix: u32) -> bool { ...@@ -122,14 +122,7 @@ pub fn is_digit(self, radix: u32) -> bool {
#[inline] #[inline]
pub fn to_digit(self, radix: u32) -> Option<u32> { pub fn to_digit(self, radix: u32) -> Option<u32> {
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)"); assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
if radix == 10 { let val = if radix <= 10 {
return match self {
'0' ..= '9' => Some(self as u32 - '0' as u32),
_ => None,
};
}
let val = if radix < 10 {
match self { match self {
'0' ..= '9' => self as u32 - '0' as u32, '0' ..= '9' => self as u32 - '0' as u32,
_ => return None, _ => return None,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册