Skip to content

Commit

Permalink
Triple capacity for transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 13, 2024
1 parent c810861 commit 2369c3e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/oxc/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ pub trait CompilerInterface {
let mut builder = SemanticBuilder::new(source_text);

if self.transform_options().is_some() {
// Estimate transformer will double scopes, symbols, references
builder = builder.with_excess_capacity(1.0);
// Estimate transformer will triple scopes, symbols, references
builder = builder.with_excess_capacity(2.0);
}

builder
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_transformer/examples/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn main() {
let mut program = ret.program;

let (symbols, scopes) = SemanticBuilder::new(&source_text)
// Estimate transformer will double scopes, symbols, references
.with_excess_capacity(1.0)
// Estimate transformer will triple scopes, symbols, references
.with_excess_capacity(2.0)
.build(&program)
.semantic
.into_symbol_table_and_scope_tree();
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ impl Oxc {

let mut semantic_builder = SemanticBuilder::new(source_text);
if run_options.transform.unwrap_or_default() {
// Estimate transformer will double scopes, symbols, references
semantic_builder = semantic_builder.with_excess_capacity(1.0);
// Estimate transformer will triple scopes, symbols, references
semantic_builder = semantic_builder.with_excess_capacity(2.0);
}
let semantic_ret = semantic_builder
.with_trivias(trivias.clone())
Expand Down
4 changes: 2 additions & 2 deletions napi/transform/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ pub fn transform(

fn transpile(ctx: &TransformContext<'_>) -> CodegenReturn {
let (symbols, scopes) = SemanticBuilder::new(ctx.source_text())
// Estimate transformer will double scopes, symbols, references
.with_excess_capacity(1.0)
// Estimate transformer will triple scopes, symbols, references
.with_excess_capacity(2.0)
.build(&ctx.program())
.semantic
.into_symbol_table_and_scope_tree();
Expand Down
4 changes: 2 additions & 2 deletions tasks/benchmark/benches/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ fn bench_transformer(criterion: &mut Criterion) {
Parser::new(&allocator, source_text, source_type).parse();
let program = allocator.alloc(program);
let (symbols, scopes) = SemanticBuilder::new(source_text)
// Estimate transformer will double scopes, symbols, references
.with_excess_capacity(1.0)
// Estimate transformer will triple scopes, symbols, references
.with_excess_capacity(2.0)
.build(program)
.semantic
.into_symbol_table_and_scope_tree();
Expand Down

0 comments on commit 2369c3e

Please sign in to comment.