Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Change the hashcounts in raw `Lit` variants from usize to u16. #49993
Conversation
This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit platforms.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
Thanks, @nnethercote! Re-assigning to @alexcrichton, since it touches |
|
@bors: r+ |
|
|
|
Out of interest, it feels like this could go lower -- I can't imagine a valid use case for more than 256 of these; did you investigate whether that would net further savings? |
|
We could get the size of |
Change the hashcounts in raw `Lit` variants from usize to u16. This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit platforms.
|
|
|
Oh, btw, the |
|
I did a rustc-perf run for this. It was a measurable win for some of the coercions and html5ever jobs:
|
The downside is that this makes Literal harder to work with -- you can't pattern match easily the way you can with Option, and creating an empty suffix involves a call to intern(). |
|
@nnethercote Note that almost nobody should be touching literals though that internal enum, only type-checking and MIR construction. Also, the empty string is preinterned: rust/src/libsyntax_pos/symbol.rs Line 302 in 64e6dda (although "Invalid" is not the best name for it - cc @petrochenkov @jseyfried) |
|
The preinterning of the empty string helps; thank you for pointing that out. But overall it's not worth getting rid of the |
This reduces the size of
Tokenfrom 32 bytes to 24 bytes on 64-bitplatforms.