Skip to content

Commit

Permalink
refactor(semantic): use Stack for function stack node ids (#7984)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Dec 18, 2024
1 parent 3631eed commit efe96ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/oxc_semantic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ doctest = false
oxc_allocator = { workspace = true }
oxc_ast = { workspace = true }
oxc_cfg = { workspace = true }
oxc_data_structures = { workspace = true }
oxc_diagnostics = { workspace = true }
oxc_ecmascript = { workspace = true }
oxc_index = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
mem,
};

use oxc_data_structures::stack::Stack;
use rustc_hash::FxHashMap;

use oxc_ast::{ast::*, AstKind, Visit};
Expand Down Expand Up @@ -77,7 +78,7 @@ pub struct SemanticBuilder<'a> {
pub(crate) current_symbol_flags: SymbolFlags,
pub(crate) current_scope_id: ScopeId,
/// Stores current `AstKind::Function` and `AstKind::ArrowFunctionExpression` during AST visit
pub(crate) function_stack: Vec<NodeId>,
pub(crate) function_stack: Stack<NodeId>,
// To make a namespace/module value like
// we need the to know the modules we are inside
// and when we reach a value declaration we set it
Expand Down Expand Up @@ -137,7 +138,7 @@ impl<'a> SemanticBuilder<'a> {
current_symbol_flags: SymbolFlags::empty(),
current_reference_flags: ReferenceFlags::empty(),
current_scope_id,
function_stack: vec![],
function_stack: Stack::with_capacity(16),
namespace_stack: vec![],
nodes: AstNodes::default(),
hoisting_variables: FxHashMap::default(),
Expand Down

0 comments on commit efe96ec

Please sign in to comment.