refactor(linter): avoid unnecessary var initialization#13072
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
CodSpeed Instrumentation Performance ReportMerging #13072 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
|
@overlookmotel graphite has done something wierd and this has ended up with conflicts |
5693ef3 to
537d2dd
Compare
There was a problem hiding this comment.
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
recordsandmodule_contentvariables - Moved variable declarations into their respective
if/elsebranches - Consolidated
allocator_guardcreation to avoid duplication
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
537d2dd to
1d77d92
Compare

Further refactor of
process_path, continuing from #13070.Avoid unnecessary pre-initialization of
recordsandmodule_content, when mostly they're overwritten later. Instead, each branch of theif/elsehold their own vars, and construct aProcessedModule.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.