Skip to content

refactor(linter): avoid unnecessary var initialization#13072

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-13-refactor_linter_avoid_unnecessary_var_initialization
Aug 14, 2025
Merged

refactor(linter): avoid unnecessary var initialization#13072
graphite-app[bot] merged 1 commit intomainfrom
08-13-refactor_linter_avoid_unnecessary_var_initialization

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 13, 2025

Further refactor of process_path, continuing from #13070.

Avoid unnecessary pre-initialization of records and module_content, when mostly they're overwritten later. Instead, each branch of the if / else hold their own vars, and construct a ProcessedModule.

There may be some tiny perf benefit of skipping the initializations, but mainly motivation is to make it more explicit what each branch returns, which personally I find makes the logic easier to follow.

Also de-duplicate creation of allocator_guard, which was previously repeated in both branches.

@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Aug 13, 2025
Copy link
Member Author

overlookmotel commented Aug 13, 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 13, 2025

CodSpeed Instrumentation Performance Report

Merging #13072 will not alter performance

Comparing 08-13-refactor_linter_avoid_unnecessary_var_initialization (1d77d92) with main (1c15288)1

Summary

✅ 34 untouched benchmarks

Footnotes

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

@overlookmotel overlookmotel marked this pull request as ready for review August 13, 2025 21:44
@overlookmotel overlookmotel requested a review from camc314 as a code owner August 13, 2025 21:44
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
Copy link
Contributor

camc314 commented Aug 14, 2025

Merge activity

  • Aug 14, 11:58 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 14, 11:58 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Aug 14, 12:05 PM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Aug 14, 8:10 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 14, 8:52 PM UTC: overlookmotel added this pull request to the Graphite merge queue.
  • Aug 14, 8:57 PM UTC: Merged by the Graphite merge queue.

@graphite-app graphite-app bot changed the base branch from 08-13-refactor_linter_reduce_repeated_code to graphite-base/13072 August 14, 2025 11:58
@graphite-app graphite-app bot changed the base branch from graphite-base/13072 to main August 14, 2025 12:04
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
@camc314
Copy link
Contributor

camc314 commented Aug 14, 2025

@overlookmotel graphite has done something wierd and this has ended up with conflicts

Copilot AI review requested due to automatic review settings August 14, 2025 20:09
@overlookmotel overlookmotel force-pushed the 08-13-refactor_linter_avoid_unnecessary_var_initialization branch from 5693ef3 to 537d2dd Compare August 14, 2025 20:09
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 refactor improves the process_path method by eliminating unnecessary variable pre-initialization and making the control flow more explicit. The changes move variable declarations closer to their usage and consolidate duplicated allocator guard creation.

  • Removed pre-initialization of records and module_content variables
  • Moved variable declarations into their respective if/else branches
  • Consolidated allocator_guard creation to avoid duplication

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
Further refactor of `process_path`, continuing from #13070.

Avoid unnecessary pre-initialization of `records` and `module_content`, when mostly they're overwritten later. Instead, each branch of the `if` / `else` hold their own vars, and construct a `ProcessedModule`.

There may be some tiny perf benefit of skipping the initializations, but mainly motivation is to make it more explicit what each branch returns, which personally I find makes the logic easier to follow.

Also de-duplicate creation of `allocator_guard`, which was previously repeated in both branches.
@graphite-app graphite-app bot force-pushed the 08-13-refactor_linter_avoid_unnecessary_var_initialization branch from 537d2dd to 1d77d92 Compare August 14, 2025 20:53
@graphite-app graphite-app bot merged commit 1d77d92 into main Aug 14, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 08-13-refactor_linter_avoid_unnecessary_var_initialization branch August 14, 2025 20:57
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter 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