Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7836843

Browse files
committed
Auto merge ofrust-lang#126750 - scottmcm:less-unlikely, r=jhpratt
Stop using `unlikely` in `strict_*` methodsThe `strict_*` methods don't need (un)likely, because the `overflow_panic` calls are all `#[cold]`, [meaning](https://llvm.org/docs/LangRef.html#function-attributes) that LLVM knows any branch to them is unlikely without us needing to say so.r? libs
2 parents934e728 +306d7bf commit7836843

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

‎core/src/num/int_macros.rs‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ macro_rules! int_impl {
484484
#[track_caller]
485485
pubconstfn strict_add(self, rhs:Self) ->Self{
486486
let(a, b) =self.overflowing_add(rhs);
487-
ifunlikely!(b){ overflow_panic::add()} else{ a}
487+
ifb{ overflow_panic::add()} else{ a}
488488
}
489489

490490
/// Unchecked integer addition. Computes `self + rhs`, assuming overflow
@@ -580,7 +580,7 @@ macro_rules! int_impl {
580580
#[track_caller]
581581
pubconstfn strict_add_unsigned(self, rhs: $UnsignedT) ->Self{
582582
let(a, b) =self.overflowing_add_unsigned(rhs);
583-
ifunlikely!(b){ overflow_panic::add()} else{ a}
583+
ifb{ overflow_panic::add()} else{ a}
584584
}
585585

586586
/// Checked integer subtraction. Computes `self - rhs`, returning `None` if
@@ -636,7 +636,7 @@ macro_rules! int_impl {
636636
#[track_caller]
637637
pubconstfn strict_sub(self, rhs:Self) ->Self{
638638
let(a, b) =self.overflowing_sub(rhs);
639-
ifunlikely!(b){ overflow_panic::sub()} else{ a}
639+
ifb{ overflow_panic::sub()} else{ a}
640640
}
641641

642642
/// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow
@@ -732,7 +732,7 @@ macro_rules! int_impl {
732732
#[track_caller]
733733
pubconstfn strict_sub_unsigned(self, rhs: $UnsignedT) ->Self{
734734
let(a, b) =self.overflowing_sub_unsigned(rhs);
735-
ifunlikely!(b){ overflow_panic::sub()} else{ a}
735+
ifb{ overflow_panic::sub()} else{ a}
736736
}
737737

738738
/// Checked integer multiplication. Computes `self * rhs`, returning `None` if
@@ -788,7 +788,7 @@ macro_rules! int_impl {
788788
#[track_caller]
789789
pubconstfn strict_mul(self, rhs:Self) ->Self{
790790
let(a, b) =self.overflowing_mul(rhs);
791-
ifunlikely!(b){ overflow_panic::mul()} else{ a}
791+
ifb{ overflow_panic::mul()} else{ a}
792792
}
793793

794794
/// Unchecked integer multiplication. Computes `self * rhs`, assuming overflow
@@ -902,7 +902,7 @@ macro_rules! int_impl {
902902
#[track_caller]
903903
pubconstfn strict_div(self, rhs:Self) ->Self{
904904
let(a, b) =self.overflowing_div(rhs);
905-
ifunlikely!(b){ overflow_panic::div()} else{ a}
905+
ifb{ overflow_panic::div()} else{ a}
906906
}
907907

908908
/// Checked Euclidean division. Computes `self.div_euclid(rhs)`,
@@ -976,7 +976,7 @@ macro_rules! int_impl {
976976
#[track_caller]
977977
pubconstfn strict_div_euclid(self, rhs:Self) ->Self{
978978
let(a, b) =self.overflowing_div_euclid(rhs);
979-
ifunlikely!(b){ overflow_panic::div()} else{ a}
979+
ifb{ overflow_panic::div()} else{ a}
980980
}
981981

982982
/// Checked integer remainder. Computes `self % rhs`, returning `None` if
@@ -1049,7 +1049,7 @@ macro_rules! int_impl {
10491049
#[track_caller]
10501050
pubconstfn strict_rem(self, rhs:Self) ->Self{
10511051
let(a, b) =self.overflowing_rem(rhs);
1052-
ifunlikely!(b){ overflow_panic::rem()} else{ a}
1052+
ifb{ overflow_panic::rem()} else{ a}
10531053
}
10541054

10551055
/// Checked Euclidean remainder. Computes `self.rem_euclid(rhs)`, returning `None`
@@ -1122,7 +1122,7 @@ macro_rules! int_impl {
11221122
#[track_caller]
11231123
pubconstfn strict_rem_euclid(self, rhs:Self) ->Self{
11241124
let(a, b) =self.overflowing_rem_euclid(rhs);
1125-
ifunlikely!(b){ overflow_panic::rem()} else{ a}
1125+
ifb{ overflow_panic::rem()} else{ a}
11261126
}
11271127

11281128
/// Checked negation. Computes `-self`, returning `None` if `self == MIN`.
@@ -1210,7 +1210,7 @@ macro_rules! int_impl {
12101210
#[track_caller]
12111211
pubconstfn strict_neg(self) ->Self{
12121212
let(a, b) =self.overflowing_neg();
1213-
ifunlikely!(b){ overflow_panic::neg()} else{ a}
1213+
ifb{ overflow_panic::neg()} else{ a}
12141214
}
12151215

12161216
/// Checked shift left. Computes `self << rhs`, returning `None` if `rhs` is larger
@@ -1273,7 +1273,7 @@ macro_rules! int_impl {
12731273
#[track_caller]
12741274
pubconstfn strict_shl(self, rhs:u32) ->Self{
12751275
let(a, b) =self.overflowing_shl(rhs);
1276-
ifunlikely!(b){ overflow_panic::shl()} else{ a}
1276+
ifb{ overflow_panic::shl()} else{ a}
12771277
}
12781278

12791279
/// Unchecked shift left. Computes `self << rhs`, assuming that
@@ -1371,7 +1371,7 @@ macro_rules! int_impl {
13711371
#[track_caller]
13721372
pubconstfn strict_shr(self, rhs:u32) ->Self{
13731373
let(a, b) =self.overflowing_shr(rhs);
1374-
ifunlikely!(b){ overflow_panic::shr()} else{ a}
1374+
ifb{ overflow_panic::shr()} else{ a}
13751375
}
13761376

13771377
/// Unchecked shift right. Computes `self >> rhs`, assuming that

‎core/src/num/uint_macros.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ macro_rules! uint_impl {
491491
#[track_caller]
492492
pubconstfn strict_add(self, rhs:Self) ->Self{
493493
let(a, b) =self.overflowing_add(rhs);
494-
ifunlikely!(b){ overflow_panic::add()} else{a}
494+
ifb{ overflow_panic::add()} else{ a}
495495
}
496496

497497
/// Unchecked integer addition. Computes `self + rhs`, assuming overflow
@@ -593,7 +593,7 @@ macro_rules! uint_impl {
593593
#[track_caller]
594594
pubconstfn strict_add_signed(self, rhs: $SignedT) ->Self{
595595
let(a, b) =self.overflowing_add_signed(rhs);
596-
ifunlikely!(b){ overflow_panic::add()} else{a}
596+
ifb{ overflow_panic::add()} else{ a}
597597
}
598598

599599
/// Checked integer subtraction. Computes `self - rhs`, returning
@@ -658,7 +658,7 @@ macro_rules! uint_impl {
658658
#[track_caller]
659659
pubconstfn strict_sub(self, rhs:Self) ->Self{
660660
let(a, b) =self.overflowing_sub(rhs);
661-
ifunlikely!(b){ overflow_panic::sub()} else{a}
661+
ifb{ overflow_panic::sub()} else{ a}
662662
}
663663

664664
/// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow
@@ -779,7 +779,7 @@ macro_rules! uint_impl {
779779
#[track_caller]
780780
pubconstfn strict_mul(self, rhs:Self) ->Self{
781781
let(a, b) =self.overflowing_mul(rhs);
782-
ifunlikely!(b){ overflow_panic::mul()} else{a}
782+
ifb{ overflow_panic::mul()} else{ a}
783783
}
784784

785785
/// Unchecked integer multiplication. Computes `self * rhs`, assuming overflow
@@ -1304,7 +1304,7 @@ macro_rules! uint_impl {
13041304
#[track_caller]
13051305
pubconstfn strict_neg(self) ->Self{
13061306
let(a, b) =self.overflowing_neg();
1307-
ifunlikely!(b){ overflow_panic::neg()} else{ a}
1307+
ifb{ overflow_panic::neg()} else{ a}
13081308
}
13091309

13101310
/// Checked shift left. Computes `self << rhs`, returning `None`
@@ -1367,7 +1367,7 @@ macro_rules! uint_impl {
13671367
#[track_caller]
13681368
pubconstfn strict_shl(self, rhs:u32) ->Self{
13691369
let(a, b) =self.overflowing_shl(rhs);
1370-
ifunlikely!(b){ overflow_panic::shl()} else{ a}
1370+
ifb{ overflow_panic::shl()} else{ a}
13711371
}
13721372

13731373
/// Unchecked shift left. Computes `self << rhs`, assuming that
@@ -1465,7 +1465,7 @@ macro_rules! uint_impl {
14651465
#[track_caller]
14661466
pubconstfn strict_shr(self, rhs:u32) ->Self{
14671467
let(a, b) =self.overflowing_shr(rhs);
1468-
ifunlikely!(b){ overflow_panic::shr()} else{ a}
1468+
ifb{ overflow_panic::shr()} else{ a}
14691469
}
14701470

14711471
/// Unchecked shift right. Computes `self >> rhs`, assuming that

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp