Skip to content

refactor(transformer): do not use &mut when & ref will do#9266

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-21-refactor_transformer_do_not_use_mut_when_ref_will_do
Feb 21, 2025
Merged

refactor(transformer): do not use &mut when & ref will do#9266
graphite-app[bot] merged 1 commit intomainfrom
02-21-refactor_transformer_do_not_use_mut_when_ref_will_do

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 21, 2025

#9253 enabled clippy's needless_pass_by_ref_mut rule, but kept it disabled for the oxc_transformer crate.

This rule is really good as using & instead of &mut may allow the compiler to make more optimizations in some cases, as & guarantees that value is not changed during the function call which takes &.

Enable this lint and fix all the warnings it highlights.

The diff is large, but it's purely replacing &mut with & in lots of places.

Copy link
Member Author

overlookmotel commented Feb 21, 2025


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 hot fixes, skip the queue and merge this PR next

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-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Feb 21, 2025
@overlookmotel overlookmotel marked this pull request as ready for review February 21, 2025 11:39
@overlookmotel
Copy link
Member Author

@Dunqing Just to flag that this PR touches many files in the transformer. Please can you merge this before any other transformer PRs, to avoid merge conflicts?

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 21, 2025

CodSpeed Performance Report

Merging #9266 will not alter performance

Comparing 02-21-refactor_transformer_do_not_use_mut_when_ref_will_do (2501c63) with main (bad08cf)

Summary

✅ 33 untouched benchmarks

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Feb 21, 2025
Copy link
Member

Boshen commented Feb 21, 2025

Merge activity

  • Feb 21, 7:46 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 21, 7:47 AM EST: A user added this pull request to the Graphite merge queue.
  • Feb 21, 7:57 AM EST: A user merged this pull request with the Graphite merge queue.

#9253 enabled clippy's `needless_pass_by_ref_mut` rule, but kept it disabled for the `oxc_transformer` crate.

This rule is really good as using `&` instead of `&mut` may allow the compiler to make more optimizations in some cases, as `&` guarantees that value is not changed during the function call which takes `&`.

Enable this lint and fix all the warnings it highlights.

The diff is large, but it's purely replacing `&mut` with `&` in lots of places.
@graphite-app graphite-app bot force-pushed the 02-21-refactor_transformer_decorators_pass_class_as_first_argument branch from 555cdf3 to f216651 Compare February 21, 2025 12:48
@graphite-app graphite-app bot force-pushed the 02-21-refactor_transformer_do_not_use_mut_when_ref_will_do branch from 1fd6df9 to 2501c63 Compare February 21, 2025 12:48
Base automatically changed from 02-21-refactor_transformer_decorators_pass_class_as_first_argument to main February 21, 2025 12:55
@graphite-app graphite-app bot merged commit 2501c63 into main Feb 21, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 02-21-refactor_transformer_do_not_use_mut_when_ref_will_do branch February 21, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-transformer Area - Transformer / Transpiler 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.

2 participants