Skip to content

Commit

Permalink
refactor(traverse): remove unnecessary branch in ChildScopeCollector (
Browse files Browse the repository at this point in the history
#5111)

Fix a mistake in `ChildScopeCollector`. `Class` always has a scope. No need to check whether it does.
  • Loading branch information
overlookmotel committed Aug 23, 2024
1 parent c100826 commit 40e2f6e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use std::{cell::Cell, str};

use compact_str::{format_compact, CompactString};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{
ast::*,
visit::{walk, Visit},
};
use oxc_ast::{ast::*, visit::Visit};
use oxc_semantic::{AstNodeId, Reference, ScopeTree, SymbolTable};
use oxc_span::{Atom, CompactStr, Span, SPAN};
use oxc_syntax::{
Expand Down Expand Up @@ -567,11 +564,7 @@ impl<'a> Visit<'a> for ChildScopeCollector {
}

fn visit_class(&mut self, class: &Class<'a>) {
if let Some(scope_id) = class.scope_id.get() {
self.scope_ids.push(scope_id);
} else {
walk::walk_class(self, class);
}
self.scope_ids.push(class.scope_id.get().unwrap());
}

fn visit_static_block(&mut self, block: &StaticBlock<'a>) {
Expand Down

0 comments on commit 40e2f6e

Please sign in to comment.