Skip to content

Commit

Permalink
Rollup merge of rust-lang#50564 - nnethercote:inline-Span-methods, r=…
Browse files Browse the repository at this point in the history
…petrochenkov

Inline `Span` methods.

Because they are simple and hot.

This change speeds up some incremental runs of a few rustc-perf
benchmarks, the best by 3%.

Here are the ones with a speedup of at least 1%:
```
coercions
        avg: -1.1%      min: -3.4%      max: -0.2%
html5ever-opt
        avg: -0.8%      min: -1.7%      max: -0.2%
clap-rs-check
        avg: -0.3%      min: -1.4%      max: 0.7%
html5ever
        avg: -0.7%      min: -1.2%      max: -0.4%
html5ever-check
        avg: -0.9%      min: -1.1%      max: -0.8%
clap-rs
        avg: -0.4%      min: -1.1%      max: -0.1%
crates.io-check
        avg: -0.8%      min: -1.0%      max: -0.6%
serde-opt
        avg: -0.6%      min: -1.0%      max: -0.3%
```
  • Loading branch information
alexcrichton authored May 10, 2018
2 parents 4199a6c + 77c40f8 commit a77ba86
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libsyntax_pos/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ pub struct Span(u32);

impl Copy for Span {}
impl Clone for Span {
#[inline]
fn clone(&self) -> Span {
*self
}
}
impl PartialEq for Span {
#[inline]
fn eq(&self, other: &Span) -> bool {
let a = self.0;
let b = other.0;
Expand All @@ -44,6 +46,7 @@ impl PartialEq for Span {
}
impl Eq for Span {}
impl Hash for Span {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
let a = self.0;
a.hash(state)
Expand Down

0 comments on commit a77ba86

Please sign in to comment.