Skip to content

refactor(ast): simplify ESTree serialization of Ident#20932

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-01-refactor_ast_simplify_estree_serialization_of_ident_
Apr 1, 2026
Merged

refactor(ast): simplify ESTree serialization of Ident#20932
graphite-app[bot] merged 1 commit intomainfrom
om/04-01-refactor_ast_simplify_estree_serialization_of_ident_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 1, 2026

Ident is always JSON-safe (cannot contain characters which require escaping in JSON). Remove #[estree(json_safe)] from fields containing Ident, and apply the JSON-safe optimization as part of Ident's ESTree impl.

This also fixes one Ident we'd missed flagging as JSON-safe previously - the Ident in PrivateIdentifier - which will be a small perf boost.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 1, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Apr 1, 2026
@overlookmotel overlookmotel marked this pull request as ready for review April 1, 2026 11:57
Copilot AI review requested due to automatic review settings April 1, 2026 11:57
@overlookmotel overlookmotel self-assigned this Apr 1, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 1, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing om/04-01-refactor_ast_simplify_estree_serialization_of_ident_ (a04f405) with main (f9ef1bd)2

Open in CodSpeed

Footnotes

  1. 8 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 (2a28e4c) during the generation of this report, so f9ef1bd was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors ESTree serialization to treat Ident as JSON-safe at the type level, removing per-field #[estree(json_safe)] annotations and relying on Ident’s ESTree impl for the optimization.

Changes:

  • Update Ident’s ESTree implementation to serialize via JsonSafeString.
  • Remove #[estree(json_safe)] from Ident fields in JS identifier AST node types.
  • Update generated ESTree serializers to serialize identifier name fields via Ident directly (instead of wrapping as_str() in JsonSafeString at call sites).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_str/src/ident.rs Moves JSON-safe serialization optimization into Ident’s ESTree impl via JsonSafeString.
crates/oxc_ast/src/generated/derive_estree.rs Switches identifier name field serialization to &self.name (delegating to Ident’s ESTree).
crates/oxc_ast/src/ast/js.rs Removes #[estree(json_safe)] from Ident-typed name fields now that Ident handles it.

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Apr 1, 2026

Merge activity

`Ident` is always JSON-safe (cannot contain characters which require escaping in JSON). Remove `#[estree(json_safe)]` from fields containing `Ident`, and apply the JSON-safe optimization as part of `Ident`'s `ESTree` impl.

This also fixes one `Ident` we'd missed flagging as JSON-safe previously - the `Ident` in `PrivateIdentifier` - which will be a small perf boost.
@graphite-app graphite-app bot force-pushed the om/04-01-docs_ast_tools_correct_doc_comment branch from a718529 to 2a28e4c Compare April 1, 2026 12:09
@graphite-app graphite-app bot requested a review from camc314 as a code owner April 1, 2026 12:09
@graphite-app graphite-app bot force-pushed the om/04-01-refactor_ast_simplify_estree_serialization_of_ident_ branch from 2fb1808 to a04f405 Compare April 1, 2026 12:09
Base automatically changed from om/04-01-docs_ast_tools_correct_doc_comment to main April 1, 2026 12:16
@graphite-app graphite-app bot merged commit a04f405 into main Apr 1, 2026
36 checks passed
@graphite-app graphite-app bot deleted the om/04-01-refactor_ast_simplify_estree_serialization_of_ident_ branch April 1, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants