Skip to content

Commit

Permalink
Remove the redundant Some(try_opt!(..)) in checked_pow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cuviper authored and Yiming Lei committed Oct 21, 2022
1 parent 3924d56 commit f310f79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f310f79

Please sign in to comment.