Skip to content

Commit 7844cb5

Browse files
committed
refactor(codegen): use Stack for binary_expr_stack (#8663)
1 parent 3be0392 commit 7844cb5

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ doctest = false
2222
[dependencies]
2323
oxc_allocator = { workspace = true }
2424
oxc_ast = { workspace = true }
25+
oxc_data_structures = { workspace = true }
2526
oxc_index = { workspace = true }
2627
oxc_mangler = { workspace = true }
2728
oxc_sourcemap = { workspace = true }

crates/oxc_codegen/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::borrow::Cow;
1818
use oxc_ast::ast::{
1919
BindingIdentifier, BlockStatement, Comment, Expression, IdentifierReference, Program, Statement,
2020
};
21+
use oxc_data_structures::stack::Stack;
2122
use oxc_mangler::Mangler;
2223
use oxc_span::{GetSpan, Span, SPAN};
2324
use oxc_syntax::{
@@ -88,7 +89,7 @@ pub struct Codegen<'a> {
8889
prev_reg_exp_end: usize,
8990
need_space_before_dot: usize,
9091
print_next_indent_as_space: bool,
91-
binary_expr_stack: Vec<BinaryExpressionVisitor<'a>>,
92+
binary_expr_stack: Stack<BinaryExpressionVisitor<'a>>,
9293
/// Indicates the output is JSX type, it is set in [`Program::gen`] and the result
9394
/// is obtained by [`oxc_span::SourceType::is_jsx`]
9495
is_jsx: bool,
@@ -166,7 +167,7 @@ impl<'a> Codegen<'a> {
166167
needs_semicolon: false,
167168
need_space_before_dot: 0,
168169
print_next_indent_as_space: false,
169-
binary_expr_stack: Vec::with_capacity(5),
170+
binary_expr_stack: Stack::with_capacity(12),
170171
prev_op_end: 0,
171172
prev_reg_exp_end: 0,
172173
prev_op: None,

0 commit comments

Comments
 (0)