Skip to content

refactor(all): pass [] for empty ArenaVec args to AST builder methods#24622

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods
Jul 17, 2026
Merged

refactor(all): pass [] for empty ArenaVec args to AST builder methods#24622
graphite-app[bot] merged 1 commit into
mainfrom
om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jul 17, 2026

Copy link
Copy Markdown
Member

Pure refactor. Just shorten code.

#24621 made AST builder methods take arrays as params.

Replace ArenaVec::new_in(...) arguments written inline at AST builder method call sites with the empty array literal [].

let block = Statement::new_block_statement(SPAN, ArenaVec::new_in(ctx), ctx);

->

let block = Statement::new_block_statement(SPAN, [], ctx);

@github-actions github-actions Bot added A-parser Area - Parser A-minifier Area - Minifier A-ast Area - AST A-transformer Area - Transformer / Transpiler A-codegen Area - Code Generation A-isolated-declarations Isolated Declarations labels Jul 17, 2026

overlookmotel commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 67 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods (c1a074c) with main (2338c13)2

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (c1a074c) during the generation of this report, so 2338c13 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel
overlookmotel force-pushed the om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods branch from 60d1e75 to 25e0cac Compare July 17, 2026 13:08
@overlookmotel
overlookmotel force-pushed the om/07-17-feat_ast_accept_arrays_for_arenavec_params_of_ast_builder_methods branch from 2d01371 to 25a9811 Compare July 17, 2026 13:08
@overlookmotel
overlookmotel marked this pull request as ready for review July 17, 2026 13:17
@overlookmotel
overlookmotel requested a review from Dunqing as a code owner July 17, 2026 13:17
Copilot AI review requested due to automatic review settings July 17, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors call sites across the codebase to use the new AST builder ergonomics introduced in #24621 by passing [] for empty ArenaVec parameters, reducing boilerplate without changing behavior.

Changes:

  • Replaces inline ArenaVec::new_in(...) empty arguments with [] for AST builder methods that now accept arrays via IntoIn.
  • Applies the same mechanical shortening in parser, transformer, minifier, isolated declarations, codegen tests, and React compiler code.
  • Cleans up an unused ArenaVec import where it became unnecessary.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_transformer/src/utils/ast_builder.rs Use [] for empty params/args/directives when building AST nodes.
crates/oxc_transformer/src/typescript/namespace.rs Use [] for empty object literal properties.
crates/oxc_transformer/src/typescript/enum.rs Use [] for empty decorators/properties/args in enum transform output.
crates/oxc_transformer/src/typescript/class.rs Use [] for empty decorators on generated class elements.
crates/oxc_transformer/src/typescript/annotations.rs Use [] for empty export specifiers and empty block statements.
crates/oxc_transformer/src/plugins/styled_components.rs Update test helper call to pass [] for empty vec arg.
crates/oxc_transformer/src/jsx/refresh.rs Use [] for placeholder/empty vecs in generated refresh AST.
crates/oxc_transformer/src/es2026/explicit_resource_management.rs Use [] for empty call arguments in generated code.
crates/oxc_transformer/src/es2022/class_static_block.rs Use [] for empty decorators and drop unused ArenaVec import.
crates/oxc_transformer/src/es2022/class_properties/constructor.rs Use [] for empty params/decorators/directives in generated functions.
crates/oxc_transformer/src/es2022/class_properties/class.rs Use [] for empty new expression argument lists.
crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs Use [] for empty decorators and empty call args.
crates/oxc_transformer/src/es2018/object_rest_spread.rs Use [] for empty object props, binding patterns, and template expressions.
crates/oxc_transformer/src/es2018/async_generator_functions/for_await.rs Use [] for empty call arguments.
crates/oxc_transformer/src/es2017/async_to_generator.rs Use [] for empty directives/call args in wrapper function generation.
crates/oxc_transformer/src/decorator/legacy/mod.rs Use [] for empty decorators/template literal expressions.
crates/oxc_transformer/src/common/duplicate.rs Use [] for empty template literal expressions vec.
crates/oxc_transformer/src/common/arrow_function_converter.rs Use [] for empty decorators and function body directives.
crates/oxc_transformer_plugins/src/module_runner_transform.rs Use [] for empty params and empty directives in generated function.
crates/oxc_react_compiler/src/react_compiler/entrypoint/program.rs Use [] for empty export specifiers / call args.
crates/oxc_react_compiler/src/react_compiler_reactive_scopes/codegen_reactive_function.rs Use [] for empty decorators/rest metadata/call args/directives.
crates/oxc_parser/src/lib.rs Pass [] for program comments placeholder (still populated later).
crates/oxc_parser/src/js/module.rs Use [] for empty export specifiers.
crates/oxc_parser/src/js/arrow.rs Use [] for empty arrow function body directives.
crates/oxc_minifier/tests/ecmascript/to_string.rs Use [] for empty object literal properties in tests.
crates/oxc_minifier/tests/ecmascript/to_number.rs Use [] for empty object literal properties in tests.
crates/oxc_minifier/tests/ecmascript/array_join.rs Use [] for empty object literal properties in tests.
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs Use [] for empty object/array literal elements in substitutions.
crates/oxc_minifier/src/peephole/remove_dead_code.rs Use [] for empty block statement body.
crates/oxc_isolated_declarations/src/module.rs Use [] for empty export specifiers.
crates/oxc_isolated_declarations/src/lib.rs Use [] for empty directives/specifiers when building new programs/exports.
crates/oxc_isolated_declarations/src/function.rs Use [] for empty parameter decorators.
crates/oxc_isolated_declarations/src/declaration.rs Use [] for empty TS module block body metadata vec.
crates/oxc_isolated_declarations/src/class.rs Use [] for empty decorators and empty signature params decorators.
crates/oxc_codegen/tests/integration/js.rs Use [] for empty template expressions and empty program comments/directives.
crates/oxc_ast/src/builder/custom.rs Use [] for empty decorators/specifiers in custom builder helpers.
crates/oxc_ast_visit/src/utf8_to_utf16/mod.rs Use [] for empty directives in test program construction.

@overlookmotel

Copy link
Copy Markdown
Member Author

@camc314 @Dunqing I'm going to merge this stack without review as I think it's uncontroversial and it touches a lot of files, so I want to get it in before it accrues merge conflicts.

Just tagging you both so you're aware we can now use this shorter syntax when the ArenaVec is being passed to an AST builder method:

  • ArenaVec::new_in(self) -> []
  • ArenaVec::from_value_in(x, self) -> [x]
  • ArenaVec::from_array_in([x, y, z], self) -> [x, y, z]

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@graphite-app

graphite-app Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merge activity

…hods (#24622)

Pure refactor. Just shorten code.

#24621 made AST builder methods take arrays as params.

Replace `ArenaVec::new_in(...)` arguments written inline at AST builder method call sites with the empty array literal `[]`.

```rs
let block = Statement::new_block_statement(SPAN, ArenaVec::new_in(ctx), ctx);
```

\->

```rs
let block = Statement::new_block_statement(SPAN, [], ctx);
```
graphite-app Bot pushed a commit that referenced this pull request Jul 17, 2026
…#24621)

Builds on #24620.

Make generated and hand-written AST builder methods take `impl IntoIn<'a, ArenaVec<'a, T>>` instead of `ArenaVec<'a, T>` for their `Vec` params, so callers can pass an array literal (e.g. `[]` or `[a, b]`) in place of building an `ArenaVec` explicitly.

This enables shortening code in a lot of places - #24622 and following PRs.
@graphite-app
graphite-app Bot force-pushed the om/07-17-feat_ast_accept_arrays_for_arenavec_params_of_ast_builder_methods branch from 25a9811 to 77230c5 Compare July 17, 2026 13:50
@graphite-app
graphite-app Bot force-pushed the om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods branch from 25e0cac to c1a074c Compare July 17, 2026 13:51
Base automatically changed from om/07-17-feat_ast_accept_arrays_for_arenavec_params_of_ast_builder_methods to main July 17, 2026 13:57
@graphite-app
graphite-app Bot merged commit c1a074c into main Jul 17, 2026
41 checks passed
@graphite-app
graphite-app Bot deleted the om/07-17-refactor_all_pass_for_empty_arenavec_args_to_ast_builder_methods branch July 17, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-codegen Area - Code Generation A-isolated-declarations Isolated Declarations A-minifier Area - Minifier A-parser Area - Parser A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants