Skip to content

Faster AcceptsResult, IsSuperTypeOfResult - #5013

Merged
staabm merged 1 commit into
phpstan:2.1.xfrom
staabm:faster334
Feb 20, 2026
Merged

staabm merged 1 commit into
phpstan:2.1.xfrom
staabm:faster334

Conversation

@staabm

@staabm staabm commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

optimize primitives for speed

@VincentLanglet

Copy link
Copy Markdown
Contributor

Do you have stat of the gain ?

@staabm

staabm commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

no.

it removes 1 method call and 1 iteration over all operands for every changed operation.
its very similar in characteristics to the other PRs recently merged

@staabm

staabm commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

before

➜  phpstan-src git:(2.1.x) ✗ hyperfine 'vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php --filter testBug14100'
Benchmark 1: vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php --filter testBug14100
  Time (mean ± σ):      1.695 s ±  0.021 s    [User: 1.521 s, System: 0.168 s]
  Range (min … max):    1.673 s …  1.731 s    10 runs

after

➜  phpstan-src git:(faster334) ✗ hyperfine 'vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php --filter testBug14100'
Benchmark 1: vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php --filter testBug14100
  Time (mean ± σ):      1.665 s ±  0.008 s    [User: 1.500 s, System: 0.160 s]
  Range (min … max):    1.656 s …  1.684 s    10 runs

@staabm
staabm marked this pull request as ready for review February 20, 2026 22:13
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet

Copy link
Copy Markdown
Contributor

it removes 1 method call and 1 iteration over all operands for every changed operation. its very similar in characteristics to the other PRs recently merged

Sure, I do agree it improve the perf ; I was curious how much

@staabm
staabm merged commit 7217179 into phpstan:2.1.x Feb 20, 2026
641 of 646 checks passed
@staabm
staabm deleted the faster334 branch February 20, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants