Skip to content

Comments

refactor(rolldown_resolver): inline unnecessary functions#6985

Closed
shulaoda wants to merge 1 commit intomainfrom
11-13-refactor_rolldown_resolver_inline_unnecessary_functions
Closed

refactor(rolldown_resolver): inline unnecessary functions#6985
shulaoda wants to merge 1 commit intomainfrom
11-13-refactor_rolldown_resolver_inline_unnecessary_functions

Conversation

@shulaoda
Copy link
Member

@shulaoda shulaoda commented Nov 13, 2025

A small helper function called only once that doesn't improve readability can be "unnecessary" - inlining makes the code more direct.

Copy link
Member Author

shulaoda commented Nov 13, 2025


How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to 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.

@hyf0
Copy link
Member

hyf0 commented Nov 13, 2025

Could you elaborate the word unnecessary here? On performance asepct or code clarity?

@shulaoda shulaoda marked this pull request as ready for review November 13, 2025 09:26
@shulaoda shulaoda requested a review from hyf0 November 13, 2025 09:26
@graphite-app graphite-app bot changed the base branch from 11-13-refactor_rolldown_resolver_move_package.json_methods_to_clone-bound_impl_block to graphite-base/6985 November 13, 2025 09:35
@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Benchmarks Rust

  • target: main(8d1a387)
  • pr: 11-13-refactor_rolldown_resolver_inline_unnecessary_functions(67b6599)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     61.2±2.18ms        ? ?/sec    1.03     63.2±0.98ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     67.6±1.19ms        ? ?/sec    1.09     73.8±2.21ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    106.1±1.43ms        ? ?/sec    1.01    106.8±1.48ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    119.1±1.52ms        ? ?/sec    1.01    120.5±1.46ms        ? ?/sec
bundle/bundle@threejs                                        1.00     38.0±1.15ms        ? ?/sec    1.02     38.8±2.28ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     41.8±0.81ms        ? ?/sec    1.01     42.1±0.43ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    386.1±4.13ms        ? ?/sec    1.03    397.4±6.51ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    445.3±3.94ms        ? ?/sec    1.03    459.5±5.77ms        ? ?/sec
scan/scan@rome_ts                                            1.00     83.3±1.15ms        ? ?/sec    1.02     84.7±1.71ms        ? ?/sec
scan/scan@threejs                                            1.00     27.9±0.37ms        ? ?/sec    1.01     28.4±0.39ms        ? ?/sec
scan/scan@threejs10x                                         1.00    293.5±3.67ms        ? ?/sec    1.00    293.0±4.94ms        ? ?/sec

@graphite-app graphite-app bot force-pushed the 11-13-refactor_rolldown_resolver_inline_unnecessary_functions branch from bbde05d to ba11494 Compare November 13, 2025 09:50
@graphite-app graphite-app bot force-pushed the graphite-base/6985 branch from 4e90a55 to 4a7d43b Compare November 13, 2025 09:50
@graphite-app graphite-app bot changed the base branch from graphite-base/6985 to main November 13, 2025 09:50
@graphite-app graphite-app bot force-pushed the 11-13-refactor_rolldown_resolver_inline_unnecessary_functions branch from ba11494 to 38cb176 Compare November 13, 2025 09:50
@netlify
Copy link

netlify bot commented Nov 13, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 67b6599
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6915edac7c287a000881383e

@shulaoda
Copy link
Member Author

Could you elaborate the word unnecessary here? On performance asepct or code clarity?

Done in PR description

@hyf0
Copy link
Member

hyf0 commented Nov 13, 2025

A small helper function called only once that doesn't improve readability can be "unnecessary" - inlining makes the code more direct.

I think the purpose of previous code extracting the function is for better readability and restricted scope.

If there's something wrong about the behavior of infering module format, you could jump into infer_module_def_format and inspect related logic. Inlining the function will make it mixed up with irrelevant logic.

Same for fn cached_package_json too. The cache behavior is considering to be an isolated logic. It adds unnecessary burden when understanding fn resolve if inlining it..

In short, these functions decrease the complexity of fn resolve.

Copilot AI review requested due to automatic review settings November 13, 2025 14:39
@shulaoda shulaoda force-pushed the 11-13-refactor_rolldown_resolver_inline_unnecessary_functions branch from 38cb176 to 67b6599 Compare November 13, 2025 14:39
Copy link
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

This PR refactors the resolver by inlining two helper functions that were only called once, making the code more direct and easier to follow.

  • Inlines cached_package_json method into its single call site within the resolve method
  • Inlines infer_module_def_format function into its single call site within the resolve method
  • Removes unused Resolution import that was only referenced in the removed function signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shulaoda
Copy link
Member Author

A small helper function called only once that doesn't improve readability can be "unnecessary" - inlining makes the code more direct.

I think the purpose of previous code extracting the function is for better readability and restricted scope.

If there's something wrong about the behavior of infering module format, you could jump into infer_module_def_format and inspect related logic. Inlining the function will make it mixed up with irrelevant logic.

Same for fn cached_package_json too. The cache behavior is considering to be an isolated logic. It adds unnecessary burden when understanding fn resolve if inlining it..

In short, these functions decrease the complexity of fn resolve.

Got it.

@shulaoda shulaoda closed this Nov 13, 2025
@shulaoda shulaoda deleted the 11-13-refactor_rolldown_resolver_inline_unnecessary_functions branch November 13, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants