mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Rollup merge of #40514 - stjepang:inline-then-ordering, r=alexcrichton
Inline functions Ordering::{then, then_with}
@jongiddy noticed bad performance due to the lack of inlining on `then`
and `then_with`. I confirmed that inlining really is the culprit by
creating a custom `then` function and repeating his benchmark on my
machine with and without the `#[inline]` attribute.
The numbers were exactly the same on my machine without the attribute.
With `#[inline]` I got the same performance as I did with manually
inlined implementation.
The problem was reported in #37053.
This commit is contained in:
@@ -277,6 +277,7 @@ pub fn reverse(self) -> Ordering {
|
||||
///
|
||||
/// assert_eq!(result, Ordering::Less);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "ordering_chaining", issue = "37053")]
|
||||
pub fn then(self, other: Ordering) -> Ordering {
|
||||
match self {
|
||||
@@ -315,6 +316,7 @@ pub fn then(self, other: Ordering) -> Ordering {
|
||||
///
|
||||
/// assert_eq!(result, Ordering::Less);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "ordering_chaining", issue = "37053")]
|
||||
pub fn then_with<F: FnOnce() -> Ordering>(self, f: F) -> Ordering {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user