diff options
| author | blake2-ppc <blake2-ppc> | 2013-08-09 19:55:15 +0200 |
|---|---|---|
| committer | blake2-ppc <blake2-ppc> | 2013-08-11 06:56:07 +0200 |
| commit | 5cfad6fbae7ab6b0a64234f53f0f22ce4169da07 (patch) | |
| tree | f8340212eb8581b6699f52360fb2f3f21b7a99d2 /src/libsyntax/parse/token.rs | |
| parent | bf809768ee8ff3ea4ef434721ff82b09a4df261a (diff) | |
| download | rust-5cfad6fbae7ab6b0a64234f53f0f22ce4169da07.tar.gz rust-5cfad6fbae7ab6b0a64234f53f0f22ce4169da07.zip | |
syntax: Shrink enum Token and enum nonterminal
`enum Token` was 192 bytes (64-bit), as pointed out by pnkfelix; the only
bloating variant being `INTERPOLATED(nonterminal)`.
Updating `enum nonterminal` to use ~ where variants included big types,
shrunk size_of(Token) to 32 bytes (64-bit).
I am unsure if the `nt_ident` variant should have an indirection, with
ast::ident being only 16 bytes (64-bit), but without this, enum Token
would be 40 bytes.
A dumb benchmark says that compilation time is unchanged, while peak
memory usage for compiling std.rs is down 3%
Before::
$ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs
19.00user 0.39system 0:19.41elapsed 99%CPU (0avgtext+0avgdata 627820maxresident)k
0inputs+28896outputs (0major+228665minor)pagefaults 0swaps
$ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs
31.64user 0.34system 0:32.02elapsed 99%CPU (0avgtext+0avgdata 629876maxresident)k
0inputs+22432outputs (0major+229411minor)pagefaults 0swaps
After::
$ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs
19.07user 0.45system 0:19.55elapsed 99%CPU (0avgtext+0avgdata 609384maxresident)k
0inputs+28896outputs (0major+221997minor)pagefaults 0swaps
$ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs
31.90user 0.34system 0:32.28elapsed 99%CPU (0avgtext+0avgdata 612080maxresident)k
0inputs+22432outputs (0major+223726minor)pagefaults 0swaps
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index c554f111bf9..bdfd25ae644 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -99,14 +99,14 @@ pub enum Token { /// For interpolation during macro expansion. pub enum nonterminal { nt_item(@ast::item), - nt_block(ast::Block), + nt_block(~ast::Block), nt_stmt(@ast::stmt), nt_pat( @ast::pat), nt_expr(@ast::expr), - nt_ty( ast::Ty), - nt_ident(ast::ident, bool), + nt_ty( ~ast::Ty), + nt_ident(~ast::ident, bool), nt_attr(@ast::Attribute), // #[foo] - nt_path( ast::Path), + nt_path(~ast::Path), nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_matchers(~[ast::matcher]) } |
