diff options
| author | Stjepan Glavina <stjepang@gmail.com> | 2017-03-14 14:01:01 +0100 |
|---|---|---|
| committer | Stjepan Glavina <stjepang@gmail.com> | 2017-03-14 14:01:01 +0100 |
| commit | 8af30132f14737a8d41db48aad9e78df396d8990 (patch) | |
| tree | 335b88758eba944137e4c847e15fa0bbbb51329d | |
| parent | fa53235cc4364fe085ccba720237d19b669c2f8b (diff) | |
| download | rust-8af30132f14737a8d41db48aad9e78df396d8990.tar.gz rust-8af30132f14737a8d41db48aad9e78df396d8990.zip | |
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.
| -rw-r--r-- | src/libcore/cmp.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index cc066099cf8..b43fe757d84 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -277,6 +277,7 @@ impl 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 @@ impl 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 { |
