diff options
| author | bors <bors@rust-lang.org> | 2021-02-16 08:38:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-02-16 08:38:11 +0000 |
| commit | f1c47c79fe8438ed241630f885797eebef3a6cab (patch) | |
| tree | 0210f035396c77bd78388f998dffd633ed6b5349 | |
| parent | 090dac0c3892a2d21afb0f82aa72920760e08078 (diff) | |
| parent | b70428b9fb08ce79ebc28c3f2c07819bba1a467d (diff) | |
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!
| -rw-r--r-- | library/core/src/char/methods.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 2baea7842a7..e450240527a 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -330,8 +330,6 @@ impl char { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn to_digit(self, radix: u32) -> Option<u32> { - 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 { @@ -340,6 +338,8 @@ impl char { _ => return None, } } else { + assert!(radix <= 36, "to_digit: radix is too high (maximum 36)"); + match self { '0'..='9' => self as u32 - '0' as u32, 'a'..='z' => self as u32 - 'a' as u32 + 10, |
