Skip to content

Remove redundant condition in findBoundingRects#36214

Open
w3di wants to merge 1 commit intofacebook:mainfrom
w3di:fix/remove-redundant-condition-test-selectors
Open

Remove redundant condition in findBoundingRects#36214
w3di wants to merge 1 commit intofacebook:mainfrom
w3di:fix/remove-redundant-condition-test-selectors

Conversation

@w3di
Copy link
Copy Markdown

@w3di w3di commented Apr 4, 2026

Summary

In ReactTestSelectors.js, the inner loop in findBoundingRects initializes j to i - 1 and decrements, so j is always strictly less than i. The condition if (i !== j) is always true and adds an unnecessary nesting level.

for (let i = boundingRects.length - 1; i > 0; i--) {
  for (let j = i - 1; j >= 0; j--) {
    if (i !== j) { // always true — j starts at i-1 and only decrements

Removed the condition and reduced indentation accordingly. No behavioral change.

How did you test this change?

Logic analysis: j is initialized to i - 1 (so j < i) and only decrements in the loop, making j always strictly less than i. The condition can never be false.

The inner loop initializes j to i - 1 and decrements, so j is always
strictly less than i. The condition `i !== j` is always true and can
be removed along with its unnecessary nesting level.
@meta-cla meta-cla bot added the CLA Signed label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant