Skip to content

Comments

Faster AcceptsResult, IsSuperTypeOfResult#5013

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

Faster AcceptsResult, IsSuperTypeOfResult#5013
staabm merged 1 commit intophpstan:2.1.xfrom
staabm:faster334

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Feb 20, 2026

optimize primitives for speed

@VincentLanglet
Copy link
Contributor

Do you have stat of the gain ?

@staabm
Copy link
Contributor Author

staabm commented Feb 20, 2026

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
Copy link
Contributor Author

staabm commented Feb 20, 2026

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
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet
Copy link
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