improve performance of signed saturating_mul
Reciprocal throughput is improved from 2.3 to 1.7. https://godbolt.org/z/ROMiX6
This commit is contained in:
parent
000d90b11f
commit
57aae75ce3
1 changed files with 1 additions and 1 deletions
|
@ -1058,7 +1058,7 @@ $EndFeature, "
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn saturating_mul(self, rhs: Self) -> Self {
|
pub fn saturating_mul(self, rhs: Self) -> Self {
|
||||||
self.checked_mul(rhs).unwrap_or_else(|| {
|
self.checked_mul(rhs).unwrap_or_else(|| {
|
||||||
if (self < 0 && rhs < 0) || (self > 0 && rhs > 0) {
|
if (self < 0) == (rhs < 0) {
|
||||||
Self::max_value()
|
Self::max_value()
|
||||||
} else {
|
} else {
|
||||||
Self::min_value()
|
Self::min_value()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue