about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-12-11 09:06:51 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2018-12-12 08:38:08 +1100
commit0f68749260d04b61dfe2b38dbc423aefe2914a58 (patch)
tree272c64f618d7b60c99b5795d749440e5e5ce0142 /src/libsyntax/parse
parentb755501043d5b27b39f94bcadd57c8d5dedfd6ba (diff)
downloadrust-0f68749260d04b61dfe2b38dbc423aefe2914a58.tar.gz
rust-0f68749260d04b61dfe2b38dbc423aefe2914a58.zip
Use a `newtype_index!` within `Symbol`.
This shrinks `Option<Symbol>` from 8 bytes to 4 bytes, which shrinks
`Token` from 24 bytes to 16 bytes. This reduces instruction counts by up
to 1% across a range of benchmarks.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/token.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 6b9cc2f9792..83763bd32d4 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -207,6 +207,10 @@ pub enum Token {
     Eof,
 }
 
+// `Token` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(target_arch = "x86_64")]
+static_assert!(MEM_SIZE_OF_STATEMENT: mem::size_of::<Token>() == 16);
+
 impl Token {
     pub fn interpolated(nt: Nonterminal) -> Token {
         Token::Interpolated(Lrc::new((nt, LazyTokenStream::new())))