diff options
| author | Josh Stone <jistone@redhat.com> | 2022-10-17 11:21:50 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2022-10-17 11:21:50 -0700 |
| commit | d7fd1d57ec90d43aee3caee75a9663914ccc1400 (patch) | |
| tree | b6aa0e83b90bf06b95a6aa39c3c8cd3ac038d4f3 | |
| parent | a9d1cafa878ecc04a4aa7aaa7df0414a29a2bd0b (diff) | |
| download | rust-d7fd1d57ec90d43aee3caee75a9663914ccc1400.tar.gz rust-d7fd1d57ec90d43aee3caee75a9663914ccc1400.zip | |
Remove the redundant `Some(try_opt!(..))` in `checked_pow`
The final return value doesn't need to be tried at all -- we can just return the checked option directly. The optimizer can probably figure this out anyway, but there's no need to make it work here.
| -rw-r--r-- | library/core/src/num/int_macros.rs | 2 | ||||
| -rw-r--r-- | library/core/src/num/uint_macros.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index b413a85fee3..81f050cb283 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -869,7 +869,7 @@ macro_rules! int_impl { // Deal with the final bit of the exponent separately, since // squaring the base afterwards is not necessary and may cause a // needless overflow. - Some(try_opt!(acc.checked_mul(base))) + acc.checked_mul(base) } /// Saturating integer addition. Computes `self + rhs`, saturating at the numeric diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index b177e5e3900..f186b468e64 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -990,7 +990,7 @@ macro_rules! uint_impl { // squaring the base afterwards is not necessary and may cause a // needless overflow. - Some(try_opt!(acc.checked_mul(base))) + acc.checked_mul(base) } /// Saturating integer addition. Computes `self + rhs`, saturating at |
