Stop using unlikely
in strict_*
methods · rust-lang/rust@a314f73 (original) (raw)
`@@ -484,7 +484,7 @@ macro_rules! int_impl {
`
484
484
` #[track_caller]
`
485
485
`pub const fn strict_add(self, rhs: Self) -> Self {
`
486
486
`let (a, b) = self.overflowing_add(rhs);
`
487
``
`-
if unlikely!(b) { overflow_panic::add() } else { a }
`
``
487
`+
if b { overflow_panic::add() } else { a }
`
488
488
`}
`
489
489
``
490
490
`` /// Unchecked integer addition. Computes self + rhs
, assuming overflow
``
`@@ -580,7 +580,7 @@ macro_rules! int_impl {
`
580
580
` #[track_caller]
`
581
581
`pub const fn strict_add_unsigned(self, rhs: $UnsignedT) -> Self {
`
582
582
`let (a, b) = self.overflowing_add_unsigned(rhs);
`
583
``
`-
if unlikely!(b) { overflow_panic::add() } else { a }
`
``
583
`+
if b { overflow_panic::add() } else { a }
`
584
584
`}
`
585
585
``
586
586
`` /// Checked integer subtraction. Computes self - rhs
, returning None
if
``
`@@ -636,7 +636,7 @@ macro_rules! int_impl {
`
636
636
` #[track_caller]
`
637
637
`pub const fn strict_sub(self, rhs: Self) -> Self {
`
638
638
`let (a, b) = self.overflowing_sub(rhs);
`
639
``
`-
if unlikely!(b) { overflow_panic::sub() } else { a }
`
``
639
`+
if b { overflow_panic::sub() } else { a }
`
640
640
`}
`
641
641
``
642
642
`` /// Unchecked integer subtraction. Computes self - rhs
, assuming overflow
``
`@@ -732,7 +732,7 @@ macro_rules! int_impl {
`
732
732
` #[track_caller]
`
733
733
`pub const fn strict_sub_unsigned(self, rhs: $UnsignedT) -> Self {
`
734
734
`let (a, b) = self.overflowing_sub_unsigned(rhs);
`
735
``
`-
if unlikely!(b) { overflow_panic::sub() } else { a }
`
``
735
`+
if b { overflow_panic::sub() } else { a }
`
736
736
`}
`
737
737
``
738
738
`` /// Checked integer multiplication. Computes self * rhs
, returning None
if
``
`@@ -788,7 +788,7 @@ macro_rules! int_impl {
`
788
788
` #[track_caller]
`
789
789
`pub const fn strict_mul(self, rhs: Self) -> Self {
`
790
790
`let (a, b) = self.overflowing_mul(rhs);
`
791
``
`-
if unlikely!(b) { overflow_panic::mul() } else { a }
`
``
791
`+
if b { overflow_panic::mul() } else { a }
`
792
792
`}
`
793
793
``
794
794
`` /// Unchecked integer multiplication. Computes self * rhs
, assuming overflow
``
`@@ -902,7 +902,7 @@ macro_rules! int_impl {
`
902
902
` #[track_caller]
`
903
903
`pub const fn strict_div(self, rhs: Self) -> Self {
`
904
904
`let (a, b) = self.overflowing_div(rhs);
`
905
``
`-
if unlikely!(b) { overflow_panic::div() } else { a }
`
``
905
`+
if b { overflow_panic::div() } else { a }
`
906
906
`}
`
907
907
``
908
908
`` /// Checked Euclidean division. Computes self.div_euclid(rhs)
,
``
`@@ -976,7 +976,7 @@ macro_rules! int_impl {
`
976
976
` #[track_caller]
`
977
977
`pub const fn strict_div_euclid(self, rhs: Self) -> Self {
`
978
978
`let (a, b) = self.overflowing_div_euclid(rhs);
`
979
``
`-
if unlikely!(b) { overflow_panic::div() } else { a }
`
``
979
`+
if b { overflow_panic::div() } else { a }
`
980
980
`}
`
981
981
``
982
982
`` /// Checked integer remainder. Computes self % rhs
, returning None
if
``
`@@ -1049,7 +1049,7 @@ macro_rules! int_impl {
`
1049
1049
` #[track_caller]
`
1050
1050
`pub const fn strict_rem(self, rhs: Self) -> Self {
`
1051
1051
`let (a, b) = self.overflowing_rem(rhs);
`
1052
``
`-
if unlikely!(b) { overflow_panic::rem() } else { a }
`
``
1052
`+
if b { overflow_panic::rem() } else { a }
`
1053
1053
`}
`
1054
1054
``
1055
1055
`` /// Checked Euclidean remainder. Computes self.rem_euclid(rhs)
, returning None
``
`@@ -1122,7 +1122,7 @@ macro_rules! int_impl {
`
1122
1122
` #[track_caller]
`
1123
1123
`pub const fn strict_rem_euclid(self, rhs: Self) -> Self {
`
1124
1124
`let (a, b) = self.overflowing_rem_euclid(rhs);
`
1125
``
`-
if unlikely!(b) { overflow_panic::rem() } else { a }
`
``
1125
`+
if b { overflow_panic::rem() } else { a }
`
1126
1126
`}
`
1127
1127
``
1128
1128
`` /// Checked negation. Computes -self
, returning None
if self == MIN
.
``
`@@ -1210,7 +1210,7 @@ macro_rules! int_impl {
`
1210
1210
` #[track_caller]
`
1211
1211
`pub const fn strict_neg(self) -> Self {
`
1212
1212
`let (a, b) = self.overflowing_neg();
`
1213
``
`-
if unlikely!(b) { overflow_panic::neg() } else { a }
`
``
1213
`+
if b { overflow_panic::neg() } else { a }
`
1214
1214
`}
`
1215
1215
``
1216
1216
`` /// Checked shift left. Computes self << rhs
, returning None
if rhs
is larger
``
`@@ -1273,7 +1273,7 @@ macro_rules! int_impl {
`
1273
1273
` #[track_caller]
`
1274
1274
`pub const fn strict_shl(self, rhs: u32) -> Self {
`
1275
1275
`let (a, b) = self.overflowing_shl(rhs);
`
1276
``
`-
if unlikely!(b) { overflow_panic::shl() } else { a }
`
``
1276
`+
if b { overflow_panic::shl() } else { a }
`
1277
1277
`}
`
1278
1278
``
1279
1279
`` /// Unchecked shift left. Computes self << rhs
, assuming that
``
`@@ -1371,7 +1371,7 @@ macro_rules! int_impl {
`
1371
1371
` #[track_caller]
`
1372
1372
`pub const fn strict_shr(self, rhs: u32) -> Self {
`
1373
1373
`let (a, b) = self.overflowing_shr(rhs);
`
1374
``
`-
if unlikely!(b) { overflow_panic::shr() } else { a }
`
``
1374
`+
if b { overflow_panic::shr() } else { a }
`
1375
1375
`}
`
1376
1376
``
1377
1377
`` /// Unchecked shift right. Computes self >> rhs
, assuming that
``