diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-11-30 10:02:04 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-12-10 12:10:10 +1100 |
| commit | 1fe2c0324006165b0c39ece0ccd7509e19583054 (patch) | |
| tree | 5212ff7760cc0de9d347ee40714a5110565a9f82 /src/libsyntax_ext | |
| parent | b755501043d5b27b39f94bcadd57c8d5dedfd6ba (diff) | |
| download | rust-1fe2c0324006165b0c39ece0ccd7509e19583054.tar.gz rust-1fe2c0324006165b0c39ece0ccd7509e19583054.zip | |
Remove `tokenstream::Delimited`.
Because it's an extra type layer that doesn't really help; in a couple of places it actively gets in the way, and overall removing it makes the code nicer. It does, however, move `tokenstream::TokenTree` further away from the `TokenTree` in `quote.rs`. More importantly, this change reduces the size of `TokenStream` from 48 bytes to 40 bytes on x86-64, which is enough to slightly reduce instruction counts on numerous benchmarks, the best by 1.5%. Note that `open_tt` and `close_tt` have gone from being methods on `Delimited` to associated methods of `TokenTree`.
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/proc_macro_server.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index 6c7da589a42..a04d6c92b78 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -64,11 +64,11 @@ impl FromInternal<(TokenStream, &'_ ParseSess, &'_ mut Vec<Self>)> let (tree, joint) = stream.as_tree(); let (span, token) = match tree { - tokenstream::TokenTree::Delimited(span, delimed) => { - let delimiter = Delimiter::from_internal(delimed.delim); + tokenstream::TokenTree::Delimited(span, delim, tts) => { + let delimiter = Delimiter::from_internal(delim); return TokenTree::Group(Group { delimiter, - stream: delimed.tts.into(), + stream: tts.into(), span, }); } @@ -232,10 +232,8 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> { }) => { return tokenstream::TokenTree::Delimited( span, - tokenstream::Delimited { - delim: delimiter.to_internal(), - tts: stream.into(), - }, + delimiter.to_internal(), + stream.into(), ) .into(); } |
