]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #50525 - nnethercote:lit_token, r=michaelwoerister
authorkennytm <kennytm@gmail.com>
Wed, 9 May 2018 09:23:31 +0000 (17:23 +0800)
committerkennytm <kennytm@gmail.com>
Wed, 9 May 2018 09:23:31 +0000 (17:23 +0800)
commit0fa08507efe4187a8056691ceb550e9da1171863
tree6b8260d2cf192a4fa0fad7967d867f974a7c8d91
parente6a309e352e10a4758a911f7ea7d2cdfd24943c3
parent65ea0ff29d32ca4fea30477f7fb1a1d43342dc26
Rollup merge of #50525 - nnethercote:lit_token, r=michaelwoerister

Optimize string handling in lit_token().

In the common case, the string value in a string literal Token is the
same as the string value in a string literal LitKind. (The exception is
when escapes or \r are involved.) This patch takes advantage of that to
avoid calling str_lit() and re-interning the string in that case. This
speeds up incremental builds for a few of the rustc-benchmarks, the best
by 3%.

Benchmarks that got a speedup of 1% or more:
```
coercions
        avg: -1.1%      min: -3.5%      max: 0.4%
regex-check
        avg: -1.2%      min: -1.5%      max: -0.6%
futures-check
        avg: -0.9%      min: -1.4%      max: -0.3%
futures
        avg: -0.8%      min: -1.3%      max: -0.3%
futures-opt
        avg: -0.7%      min: -1.2%      max: -0.1%
regex
        avg: -0.5%      min: -1.2%      max: -0.1%
regex-opt
        avg: -0.5%      min: -1.1%      max: -0.1%
hyper-check
        avg: -0.7%      min: -1.0%      max: -0.3%
```