-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce size of ReferenceId
and SymbolId
in AST
#1
Comments
Can I use https://crates.io/crates/nonmax This didn't exist 6 months so I was too lazy to add a rustc has an internal |
I hate rust
Same error for |
Ahhh
|
Good news is we forked |
Open to public oxc-project/oxc#3318 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReferenceId
andSymbolId
areu32
. In the AST, they're stored asCell<Option<Id>>
.https://github.com/oxc-project/oxc/blob/b9d69ad665ab386233f940e9f1a9b3095a2238dc/crates/oxc_ast/src/ast/js.rs#L428
https://github.com/oxc-project/oxc/blob/b9d69ad665ab386233f940e9f1a9b3095a2238dc/crates/oxc_ast/src/ast/js.rs#L456
semantic's
ScopeTree
also containsparent_ids: IndexVec<ScopeId, Option<ScopeId>>
https://github.com/oxc-project/oxc/blob/b9d69ad665ab386233f940e9f1a9b3095a2238dc/crates/oxc_semantic/src/scope.rs#L23
u32
has no niche, soOption<u32>
is 8 bytes.This makes
oxc::ast::IdentifierReference
8 bytes larger than it needs to be, because itsreference_flag: ReferenceFlag
field is an extra byte, but gets followed by 7 bytes of padding.IdentifierReference
is very common in the AST.We should either:
NonZeroU32
to give them a niche.or
Cell<Option<Id>>
. Just useCell<Id>
and use 0 as a default value. 0 can mean "global scope" or "undefined".I prefer option 2. Then we don't have to unwrap the
Option
all the time, which may remove panic code.The text was updated successfully, but these errors were encountered: