Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_minifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ oxc_ast = { workspace = true }
oxc_ast_visit = { workspace = true }
oxc_codegen = { workspace = true }
oxc_compat = { workspace = true }
oxc_data_structures = { workspace = true, features = ["stack"] }
oxc_ecmascript = { workspace = true }
oxc_mangler = { workspace = true }
oxc_parser = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'a> Traverse<'a, MinifierState<'a>> for PeepholeOptimizations {
ctx.scoping_mut().delete_reference(*reference_id_to_remove);
}
}
debug_assert!(ctx.state.class_symbols_stack.is_empty());
debug_assert!(ctx.state.class_symbols_stack.is_exhausted());
}

fn exit_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>, ctx: &mut TraverseCtx<'a>) {
Expand Down
17 changes: 8 additions & 9 deletions crates/oxc_minifier/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use oxc_ecmascript::constant_evaluation::ConstantValue;
use rustc_hash::{FxHashMap, FxHashSet};

use oxc_data_structures::stack::NonEmptyStack;
use oxc_span::{Atom, SourceType};
use oxc_syntax::symbol::SymbolId;

Expand Down Expand Up @@ -37,17 +38,17 @@ impl MinifierState<'_> {

/// Stack to track class symbol information
pub struct ClassSymbolsStack<'a> {
stack: Vec<FxHashSet<Atom<'a>>>,
stack: NonEmptyStack<FxHashSet<Atom<'a>>>,
}

impl<'a> ClassSymbolsStack<'a> {
pub fn new() -> Self {
Self { stack: Vec::new() }
Self { stack: NonEmptyStack::new(FxHashSet::default()) }
}

/// Check if the stack is empty
pub fn is_empty(&self) -> bool {
self.stack.is_empty()
/// Check if the stack is exhausted
pub fn is_exhausted(&self) -> bool {
self.stack.is_exhausted()
}

/// Enter a new class scope
Expand All @@ -62,13 +63,11 @@ impl<'a> ClassSymbolsStack<'a> {

/// Add a private member to the current class scope
pub fn push_private_member_to_current_class(&mut self, name: Atom<'a>) {
if let Some(current_class) = self.stack.last_mut() {
current_class.insert(name);
}
self.stack.last_mut().insert(name);
}

/// Check if a private member is used in the current class scope
pub fn is_private_member_used_in_current_class(&self, name: &Atom<'a>) -> bool {
self.stack.last().is_some_and(|current_class| current_class.contains(name))
self.stack.last().contains(name)
}
}
6 changes: 3 additions & 3 deletions tasks/track_memory_allocations/allocs_minifier.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ checker.ts | 2.92 MB || 84074 | 14190 |

cal.com.tsx | 1.06 MB || 40526 | 3033 || 37074 | 4733 | 1.654 MB

RadixUIAdoptionSection.jsx | 2.52 kB || 82 | 8 || 30 | 6 | 992 B
RadixUIAdoptionSection.jsx | 2.52 kB || 83 | 8 || 30 | 6 | 992 B

pdf.mjs | 567.30 kB || 19823 | 2900 || 47400 | 7781 | 1.624 MB

antd.js | 6.69 MB || 99854 | 13518 || 331725 | 70117 | 17.407 MB
antd.js | 6.69 MB || 99855 | 13518 || 331725 | 70117 | 17.407 MB

binder.ts | 193.08 kB || 4768 | 974 || 7059 | 834 | 201.192 kB
binder.ts | 193.08 kB || 4769 | 974 || 7059 | 834 | 201.192 kB

Loading