about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-02-15 09:10:02 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2019-02-18 09:46:33 +1100
commitf8801f3bf641f0277087e6621d09f9a6a373b36c (patch)
treed58803ac7c531e5911f4f3e17d843f80ac401708 /src/libsyntax/print
parentd26bf742db0754893567401e49ae8b016c878a92 (diff)
downloadrust-f8801f3bf641f0277087e6621d09f9a6a373b36c.tar.gz
rust-f8801f3bf641f0277087e6621d09f9a6a373b36c.zip
Remove `LazyTokenStream`.
It's present within `Token::Interpolated` as an optimization, so that if
a nonterminal is converted to a `TokenStream` multiple times, the
first-computed value is saved and reused.

But in practice it's not needed. `interpolated_to_tokenstream()` is a
cold function: it's only called a few dozen times while compiling rustc
itself, and a few hundred times across the entire `rustc-perf` suite.
Furthermore, when it is called, it is almost always the first
conversion, so no benefit is gained from it.

So this commit removes `LazyTokenStream`, along with the now-unnecessary
`Token::interpolated()`.

As well as a significant simplification, the removal speeds things up
slightly, mostly due to not having to `drop` the `LazyTokenStream`
instances.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 0e48e3a5dff..dcf9815f6d1 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -257,7 +257,7 @@ pub fn token_to_string(tok: &Token) -> String {
         token::Comment              => "/* */".to_string(),
         token::Shebang(s)           => format!("/* shebang: {}*/", s),
 
-        token::Interpolated(ref nt) => nonterminal_to_string(&nt.0),
+        token::Interpolated(ref nt) => nonterminal_to_string(nt),
     }
 }