Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Oct 18, 2025

Optimize SourceCode#getAncestors:

  • Remove temp var ancestor.
  • Reduce code repetition.
  • Check for end of loop with === null (instead of truthiness test).

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI labels Oct 18, 2025
Copy link
Member Author


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 the C-performance Category - Solution not expected to change functional behavior, only performance label Oct 18, 2025
@overlookmotel overlookmotel marked this pull request as ready for review October 18, 2025 10:37
Copilot AI review requested due to automatic review settings October 18, 2025 10:37
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 optimizes the getAncestors function in the SourceCode plugin by refactoring the loop structure for better performance. The changes simplify the code by eliminating a temporary variable and improving the loop termination condition.

  • Replaced for-loop with while-loop to remove temporary ancestor variable
  • Changed loop termination from truthiness check to explicit === null comparison
  • Reduced code repetition by consolidating parent access logic

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

@overlookmotel overlookmotel self-assigned this Oct 18, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Oct 18, 2025
Copy link
Member Author

overlookmotel commented Oct 18, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Oct 18, 2025
Optimize `SourceCode#getAncestors`:

* Remove temp var `ancestor`.
* Reduce code repetition.
* Check for end of loop with `=== null` (instead of truthiness test).
@graphite-app graphite-app bot force-pushed the 10-18-perf_linter_plugins_speed_up_sourcecode_getancestors_ branch from 90ab539 to cdd9b1b Compare October 18, 2025 10:42
@overlookmotel overlookmotel force-pushed the 10-18-perf_linter_plugins_speed_up_sourcecode_getancestors_ branch from cdd9b1b to 93e9ef6 Compare October 18, 2025 10:43
Optimize `SourceCode#getAncestors`:

* Remove temp var `ancestor`.
* Reduce code repetition.
* Check for end of loop with `=== null` (instead of truthiness test).
@graphite-app graphite-app bot force-pushed the 10-18-perf_linter_plugins_speed_up_sourcecode_getancestors_ branch from 93e9ef6 to e6f351d Compare October 18, 2025 10:44
@graphite-app graphite-app bot merged commit e6f351d into main Oct 18, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 10-18-perf_linter_plugins_speed_up_sourcecode_getancestors_ branch October 18, 2025 10:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants