about summary refs log tree commit diff
path: root/src/libsyntax/ext/source_util.rs
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2016-10-19 07:59:59 +0300
committerGitHub <noreply@github.com>2016-10-19 07:59:59 +0300
commitaaed275a49ccc90eec4b2cbd8fc5d29c8f2115f7 (patch)
tree3fa84ab51170df2f7e5706d6030f254b9ef9c5af /src/libsyntax/ext/source_util.rs
parenta88ca4bf8ec0775cf517b1b3eaf0ec116194a4fd (diff)
parent029dceedb9719ae5dbdbf2c033c920017e3d786e (diff)
downloadrust-aaed275a49ccc90eec4b2cbd8fc5d29c8f2115f7.tar.gz
rust-aaed275a49ccc90eec4b2cbd8fc5d29c8f2115f7.zip
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
Diffstat (limited to 'src/libsyntax/ext/source_util.rs')
-rw-r--r--src/libsyntax/ext/source_util.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index e75e41d0c2d..30dc1823b37 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -94,7 +94,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::T
     // The file will be added to the code map by the parser
     let p =
         parse::new_sub_parser_from_file(cx.parse_sess(),
-                                        cx.cfg(),
+                                        cx.cfg().clone(),
                                         &res_rel_file(cx,
                                                       sp,
                                                       Path::new(&file)),