mirror of
https://github.com/rust-lang/rust
synced 2024-09-30 22:04:36 +00:00
Auto merge of #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.
This commit is contained in:
commit
c1bb0e0911
|
@ -1321,13 +1321,13 @@ fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
|
|||
(true, true) => Some(Equal),
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
|
||||
}
|
||||
)*)
|
||||
|
@ -1359,13 +1359,13 @@ impl PartialOrd for $t {
|
|||
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue