Skip to content

Commit f1c47c7

Browse files
committed
Auto merge of #82058 - gilescope:to_digit_speedup, r=lcnr
no need to check assertion on fast path as will always hold. V small change. Easy to review though!
2 parents 090dac0 + b70428b commit f1c47c7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: library/core/src/char/methods.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,6 @@ impl char {
330330
#[stable(feature = "rust1", since = "1.0.0")]
331331
#[inline]
332332
pub fn to_digit(self, radix: u32) -> Option<u32> {
333-
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
334-
335333
// the code is split up here to improve execution speed for cases where
336334
// the `radix` is constant and 10 or smaller
337335
let val = if radix <= 10 {
@@ -340,6 +338,8 @@ impl char {
340338
_ => return None,
341339
}
342340
} else {
341+
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
342+
343343
match self {
344344
'0'..='9' => self as u32 - '0' as u32,
345345
'a'..='z' => self as u32 - 'a' as u32 + 10,

0 commit comments

Comments
 (0)