Skip to content

Commit

Permalink
Refactor: More efficient scope creation
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Oct 30, 2024
1 parent 87303b0 commit 366cc8f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/oxc_transformer/src/es2022/class_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use serde::Deserialize;

use oxc_ast::{ast::*, AstBuilder, NONE};
use oxc_span::SPAN;
use oxc_syntax::{scope::ScopeFlags, symbol::SymbolFlags};
use oxc_syntax::{node::NodeId, scope::ScopeFlags, symbol::SymbolFlags};
use oxc_traverse::{Ancestor, Traverse, TraverseCtx};

use crate::{common::helper_loader::Helper, TransformCtx};
Expand Down Expand Up @@ -213,8 +213,12 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
ctx: &mut TraverseCtx<'a>,
) {
// Create scope for constructor
let scope_id =
ctx.create_child_scope_of_current(ScopeFlags::Function | ScopeFlags::Constructor);
let parent_scope_id = ctx.current_scope_id();
let scope_id = ctx.scopes_mut().add_scope(
Some(parent_scope_id),
NodeId::DUMMY,
ScopeFlags::Function | ScopeFlags::Constructor | ScopeFlags::StrictMode,
);

// Create statements to go in function body.
let mut stmts = ctx.ast.vec_with_capacity(inits.len() + has_super_class as usize);
Expand Down

0 comments on commit 366cc8f

Please sign in to comment.