1
Fork 0

Rollup merge of #37161 - nnethercote:no-cfg-cloning, r=nrc

Avoid many CrateConfig clones.

This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig`
reference instead of a clone. As a result, it also changes all of the
`cfg()` callsites to explicitly clone... except one, because the commit
also changes `macro_parser::parse()` to take `&CrateConfig`. This is
good, because that function can be hot, and `CrateConfig` is expensive
to clone.

This change almost halves the number of heap allocations done by rustc
for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x
faster.

r? @nrc
This commit is contained in:
Eduard-Mihai Burtescu 2016-10-19 07:59:59 +03:00 committed by GitHub
commit aaed275a49
8 changed files with 18 additions and 14 deletions

View file

@ -107,7 +107,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
if p2.token != token::Eof {
let mut extra_tts = panictry!(p2.parse_all_token_trees());
extra_tts.extend(tts[first_colon..].iter().cloned());
p = parse::tts_to_parser(cx.parse_sess, extra_tts, cx.cfg());
p = parse::tts_to_parser(cx.parse_sess, extra_tts, cx.cfg().clone());
}
asm = s;