about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-12-14 22:10:09 +0800
committerGitHub <noreply@github.com>2018-12-14 22:10:09 +0800
commitdadf7fcc2dc76dd90a9f5a4eea595cf7add8ffff (patch)
treea9ba7855dc14b44d546cc4b0d2f3509edd68e80e /src/libsyntax/parse/token.rs
parent53a2de2d549f8f3af99de7c05fa8caa7aa2f2949 (diff)
parent0f68749260d04b61dfe2b38dbc423aefe2914a58 (diff)
downloadrust-dadf7fcc2dc76dd90a9f5a4eea595cf7add8ffff.tar.gz
rust-dadf7fcc2dc76dd90a9f5a4eea595cf7add8ffff.zip
Rollup merge of #56699 - nnethercote:SymbolIndex, r=oli-obk
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.

r? @oli-obk
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-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 8e4d3c0166b..ed746657459 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())))