about summary refs log tree commit diff
path: root/src/libsyntax/attr
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-10-10 07:29:02 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2019-10-14 09:14:39 +1100
commit5c93492da914f972fb549e95db778adcbdf70480 (patch)
treec80325183ecf62fe27acb5444fc27d255e8180b2 /src/libsyntax/attr
parent20cc75272619cc452e3ae6c131e61974f6aa9929 (diff)
downloadrust-5c93492da914f972fb549e95db778adcbdf70480.tar.gz
rust-5c93492da914f972fb549e95db778adcbdf70480.zip
Remove the `Option` in `TokenStream`.
It means an allocation is required to create an empty `TokenStream`, but
all other operations are simpler and marginally faster due to not having
to check for `None`. Overall it simplifies the code for a negligible
performance effect.

The commit also removes `TokenStream::empty` by implementing `Default`,
which is now possible.
Diffstat (limited to 'src/libsyntax/attr')
-rw-r--r--src/libsyntax/attr/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs
index 7bef693a5be..c2c883fd20e 100644
--- a/src/libsyntax/attr/mod.rs
+++ b/src/libsyntax/attr/mod.rs
@@ -551,7 +551,7 @@ impl MetaItem {
 impl MetaItemKind {
     pub fn tokens(&self, span: Span) -> TokenStream {
         match *self {
-            MetaItemKind::Word => TokenStream::empty(),
+            MetaItemKind::Word => TokenStream::default(),
             MetaItemKind::NameValue(ref lit) => {
                 let mut vec = vec![TokenTree::token(token::Eq, span).into()];
                 lit.tokens().append_to_tree_and_joint_vec(&mut vec);