Skip to content

[perf] Skip native type resolution in SimplifyBoolIdenticalTrueRector unless true/false literal present - #8578

Merged
TomasVotruba merged 1 commit into
mainfrom
perf-simplify-bool-identical-true
Oct 10, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
perf-simplify-bool-identical-true

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

SimplifyBoolIdenticalTrueRector ran getNativeType() on both sides of every ===/!== node, even though it can only fire when one side is a literal true/false.

Most identical comparisons in real code compare against non-bool operands ($a === $b, === null, === 0), so the type resolution was pure overhead.

Reorder: check the cheap isTrueOrFalse() on the opposite operand first, and only run the expensive native type resolution when a bool literal is actually present. Behavior unchanged - all existing cases ($b === true, true === $b, !$x === false, both-literal) resolve identically.

@TomasVotruba
TomasVotruba merged commit f06cc08 into main Oct 10, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-simplify-bool-identical-true branch October 10, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant