Skip to content

Commit f646e43

Browse files
committed
Slightly simplify the iN::partial_cmp MIR
This saves some debug and scope metadata in every single function that calls it. Normally wouldn't be worth it, but with the derives there's *so* many of these.
1 parent f610834 commit f646e43

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

core/src/cmp.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,14 @@ mod impls {
15481548
impl PartialOrd for $t {
15491549
#[inline]
15501550
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
1551-
Some(self.cmp(other))
1551+
#[cfg(bootstrap)]
1552+
{
1553+
Some(self.cmp(other))
1554+
}
1555+
#[cfg(not(bootstrap))]
1556+
{
1557+
Some(crate::intrinsics::three_way_compare(*self, *other))
1558+
}
15521559
}
15531560
#[inline(always)]
15541561
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
@@ -1566,12 +1573,12 @@ mod impls {
15661573
fn cmp(&self, other: &$t) -> Ordering {
15671574
#[cfg(bootstrap)]
15681575
{
1569-
// The order here is important to generate more optimal assembly.
1570-
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
1571-
if *self < *other { Less }
1572-
else if *self == *other { Equal }
1573-
else { Greater }
1574-
}
1576+
// The order here is important to generate more optimal assembly.
1577+
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
1578+
if *self < *other { Less }
1579+
else if *self == *other { Equal }
1580+
else { Greater }
1581+
}
15751582
#[cfg(not(bootstrap))]
15761583
{
15771584
crate::intrinsics::three_way_compare(*self, *other)

0 commit comments

Comments
 (0)