rust-analyzer / rowan

Apache License 2.0
697 stars 57 forks source link

Use thin-dst in GreenNode #42

Closed CAD97 closed 4 years ago

CAD97 commented 4 years ago

On top of #41. (Theoretically disjoint, but no size benefit without.)

Uses thin-dst to store GreenNode's kind, text_len, and children all inline in a single allocation, behind a thin pointer.

GreenElement can theoretically be further squished from 2×usize to 1×usize by using alignment bits to tag whether the pointer is a node or a token. That will be proposed in a follow-up PR.

r? @matklad

Size comparison Before: ``` GreenNode 24 GreenToken 8 GreenElement 32 SyntaxNode 8 SyntaxToken 16 SyntaxElement 24 ``` After: ``` GreenNode 8 GreenToken 8 GreenElement 16 SyntaxNode 8 SyntaxToken 16 SyntaxElement 24 ```
matklad commented 4 years ago

bors r+

bors[bot] commented 4 years ago

Build succeeded