-
-
Notifications
You must be signed in to change notification settings - Fork 646
Closed
Description
Semantic's ScopeTree
consists mostly of IndexVec
s, but 2 fields are FxHashMap
s.
oxc/crates/oxc_semantic/src/scope.rs
Lines 21 to 32 in 95e9b69
pub struct ScopeTree { | |
/// Maps a scope to the parent scope it belongs in | |
parent_ids: IndexVec<ScopeId, Option<ScopeId>>, | |
/// Maps a scope to direct children scopes | |
child_ids: FxHashMap<ScopeId, Vec<ScopeId>>, | |
// Maps a scope to its node id | |
node_ids: FxHashMap<ScopeId, AstNodeId>, | |
flags: IndexVec<ScopeId, ScopeFlags>, | |
bindings: IndexVec<ScopeId, Bindings>, | |
unresolved_references: IndexVec<ScopeId, UnresolvedReferences>, | |
} |
I'm not sure why child_ids
and node_ids
are hash maps, but imagine they could be changed to IndexVec
s, which have faster lookup. If for some reason a few scopes don't get records in these fields at present, we could just insert dummies in those cases. Then ScopeId
can be used to index them.
Metadata
Metadata
Assignees
Labels
No labels