Skip to content

Commit b45a233

Browse files
authored
Rollup merge of #96124 - gilescope:to_digit_speedup4, r=thomcc
to_digit tweak No need to check the assert all the time. (Checked the TODO and it's not time to get rid of it yet)
2 parents 2da2934 + bf02d1e commit b45a233

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/char/methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ impl char {
343343
without modifying the original"]
344344
#[inline]
345345
pub const fn to_digit(self, radix: u32) -> Option<u32> {
346-
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
347346
// If not a digit, a number greater than radix will be created.
348347
let mut digit = (self as u32).wrapping_sub('0' as u32);
349348
if radix > 10 {
349+
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
350350
if digit < 10 {
351351
return Some(digit);
352352
}

0 commit comments

Comments
 (0)