Skip to content

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 14, 2025

No description provided.

@github-actions github-actions bot added A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance labels Dec 14, 2025
Copy link
Contributor Author

camc314 commented Dec 14, 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.

@camc314 camc314 marked this pull request as ready for review December 14, 2025 17:11
@camc314 camc314 self-assigned this Dec 14, 2025
Copy link

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found with this change. The added break; is a clear, safe micro-optimization that also prevents duplicate diagnostics once a match has been handled.

Additional notes (1)
  • Maintainability | crates/oxc_linter/src/rules/oxc/approx_constant.rs:67-71
    Adding break after the first diagnostic changes behavior if the loop could legitimately find multiple approximate constants that should each be reported for the same number_literal/node (or if the loop is iterating over multiple candidate constants to choose a best match). If multiple reports were previously possible/desired, this will silently reduce diagnostics to one.

Given the PR title, that may be intentional, but the code currently doesn’t make it obvious that the first match is the correct/only match (e.g., if candidate ordering changes, you might report a less-ideal constant). Consider ensuring determinism/quality by explicitly selecting the best match (or documenting that candidates are mutually exclusive / ordered by preference).

Summary of changes

What changed

  • In ApproxConstant rule, added a break; immediately after emitting a diagnostic via ctx.diagnostic_with_suggestion(...).
  • This stops iterating after the first match is found, reducing unnecessary loop iterations and avoiding multiple diagnostics for the same visit.

Key code change

  • Added break; after the diagnostic call within the loop that searches for an approximate constant match.

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 14, 2025 17:12
@graphite-app graphite-app bot changed the base branch from c/12-14-feat_linter_approx-constant_implement_fixer to graphite-base/16848 December 14, 2025 17:14
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 14, 2025

Merge activity

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #16848 will not alter performance

Comparing c/12-14-perf_linter_approx-constant_break_after_first_match_to_avoid_extra_iterations (e86da34) with main (2f77a1a)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@graphite-app graphite-app bot changed the base branch from graphite-base/16848 to main December 14, 2025 17:19
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
Copilot AI review requested due to automatic review settings December 14, 2025 18:05
@camc314 camc314 force-pushed the c/12-14-perf_linter_approx-constant_break_after_first_match_to_avoid_extra_iterations branch from 21ffa11 to e86da34 Compare December 14, 2025 18:05
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 adds a performance optimization to the approx_constant linter rule by breaking out of the loop after finding the first matching constant, avoiding unnecessary iterations through the remaining constants.

  • Adds a break statement after the first constant match is found and reported

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

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
@graphite-app graphite-app bot force-pushed the c/12-14-perf_linter_approx-constant_break_after_first_match_to_avoid_extra_iterations branch from e86da34 to 9c1be35 Compare December 14, 2025 18:16
@graphite-app graphite-app bot merged commit 9c1be35 into main Dec 14, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/12-14-perf_linter_approx-constant_break_after_first_match_to_avoid_extra_iterations branch December 14, 2025 18:21
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 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-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