diff options
| author | Trevor Spiteri <tspiteri@ieee.org> | 2019-10-11 17:13:19 +0200 |
|---|---|---|
| committer | Trevor Spiteri <tspiteri@ieee.org> | 2019-10-11 17:13:19 +0200 |
| commit | 57aae75ce39de12f1af8d33d2836db59f7269ed2 (patch) | |
| tree | e31756744ec1988079a14a8a7e3c25e7ae5b76b9 | |
| parent | 000d90b11f7be70ffb7812680f7abc6deb52ec88 (diff) | |
| download | rust-57aae75ce39de12f1af8d33d2836db59f7269ed2.tar.gz rust-57aae75ce39de12f1af8d33d2836db59f7269ed2.zip | |
improve performance of signed saturating_mul
Reciprocal throughput is improved from 2.3 to 1.7. https://godbolt.org/z/ROMiX6
| -rw-r--r-- | src/libcore/num/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index ebde82de834..998c8f81652 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1058,7 +1058,7 @@ $EndFeature, " #[inline] pub fn saturating_mul(self, rhs: Self) -> Self { self.checked_mul(rhs).unwrap_or_else(|| { - if (self < 0 && rhs < 0) || (self > 0 && rhs > 0) { + if (self < 0) == (rhs < 0) { Self::max_value() } else { Self::min_value() |
