Skip to content

Commit c1bb0e0

Browse files
committed
Auto merge of rust-lang#110935 - scottmcm:always-ord, r=Mark-Simulacrum
`inline(always)` for `lt`/`le`/`ge`/`gt` on integers and floats I happened to notice one of these not getting inlined as part of `Range::next` in <https://rust.godbolt.org/z/4WKWWxj1G> ```rust bb1: { StorageLive(_5); _6 = &mut _4; StorageLive(_21); StorageLive(_14); StorageLive(_15); _15 = &((*_6).0: usize); StorageLive(_16); _16 = &((*_6).1: usize); _14 = <usize as PartialOrd>::lt(move _15, move _16) -> bb7; } ``` So since a call for something that's just one instruction is never the right choice, `#[inline(always)]` seems appropriate, like we have it on things like the rotate methods on integers.
2 parents d3edfd1 + 8857cc2 commit c1bb0e0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

library/core/src/cmp.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1321,13 +1321,13 @@ mod impls {
13211321
(true, true) => Some(Equal),
13221322
}
13231323
}
1324-
#[inline]
1324+
#[inline(always)]
13251325
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
1326-
#[inline]
1326+
#[inline(always)]
13271327
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
1328-
#[inline]
1328+
#[inline(always)]
13291329
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
1330-
#[inline]
1330+
#[inline(always)]
13311331
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
13321332
}
13331333
)*)
@@ -1359,13 +1359,13 @@ mod impls {
13591359
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
13601360
Some(self.cmp(other))
13611361
}
1362-
#[inline]
1362+
#[inline(always)]
13631363
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
1364-
#[inline]
1364+
#[inline(always)]
13651365
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
1366-
#[inline]
1366+
#[inline(always)]
13671367
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
1368-
#[inline]
1368+
#[inline(always)]
13691369
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
13701370
}
13711371

0 commit comments

Comments
 (0)