diff options
| author | bors <bors@rust-lang.org> | 2016-07-06 20:04:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-06 20:04:11 -0700 |
| commit | de78655bca47cac8e783dbb563e7e5c25c1fae40 (patch) | |
| tree | 1e74a08a79b8d12f5166600f3ca19c449d7732ad /src/libsyntax/tokenstream.rs | |
| parent | 5c674a11471ec0569f616854d715941757a48a0a (diff) | |
| parent | 547a930835be262ebea5e499dba7555a8a47b992 (diff) | |
| download | rust-de78655bca47cac8e783dbb563e7e5c25c1fae40.tar.gz rust-de78655bca47cac8e783dbb563e7e5c25c1fae40.zip | |
Auto merge of #34652 - jseyfried:fix_expansion_perf, r=nrc
Fix expansion performance regression **syntax-[breaking-change] cc #31645** This fixes #34630 by reverting commit 5bf7970 of PR #33943, which landed in #34424. By removing the `Rc<_>` wrapping around `Delimited` and `SequenceRepetition` in `TokenTree`, 5bf7970 made cloning `TokenTree`s more expensive. While this had no measurable performance impact on the compiler's crates, it caused an order of magnitude performance regression on some macro-heavy code in the wild. I believe this is due to clones of `TokenTree`s in `macro_parser.rs` and/or `macro_rules.rs`. r? @nrc
Diffstat (limited to 'src/libsyntax/tokenstream.rs')
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 35377d14bab..f0f0a7bc580 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -21,6 +21,8 @@ use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; use parse::lexer; use parse::token; +use std::rc::Rc; + /// A delimited sequence of token trees #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Delimited { @@ -94,13 +96,13 @@ pub enum TokenTree { /// A single token Token(Span, token::Token), /// A delimited sequence of token trees - Delimited(Span, Delimited), + Delimited(Span, Rc<Delimited>), // This only makes sense in MBE macros. /// A kleene-style repetition sequence with a span // FIXME(eddyb) #12938 Use DST. - Sequence(Span, SequenceRepetition), + Sequence(Span, Rc<SequenceRepetition>), } impl TokenTree { @@ -149,7 +151,7 @@ impl TokenTree { Some(*cnt) }).max().unwrap_or(0); - TokenTree::Delimited(sp, Delimited { + TokenTree::Delimited(sp, Rc::new(Delimited { delim: token::Bracket, open_span: sp, tts: vec![TokenTree::Token(sp, token::Ident(token::str_to_ident("doc"))), @@ -157,7 +159,7 @@ impl TokenTree { TokenTree::Token(sp, token::Literal( token::StrRaw(token::intern(&stripped), num_of_hashes), None))], close_span: sp, - }) + })) } (&TokenTree::Delimited(_, ref delimed), _) => { if index == 0 { |
