fix: Faster StatementIndentationFixer #7957
Open
+8
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when re-ordering the conditions we highly reduce the number of function calls happening in a regular code base.
As PHP (tested on 8.2.12) is pretty fast, the change itself does not yield much improvements regarding runtime.
As soon as php-extensions like xdebug, blackfire or other dev-tools which incur a perf penalty on function calls are in the game we see improvements though.
running php-cs-fixer on one of our closed source projects before this PR and a php.ini like
makes a big difference though (so xdebug is just loaded).
3 runs before this PR:
1m5s, 1m11s, 1m8s
3 runs after this PR:
44s, 41s, 45s
I think people having xdebug loaded while daily work while running a dev tool like php-cs-fixer is not unusal.
additionally by removing function calls we improve php-cs-fixer beeing profiled, because xdebug and blackfire currently are not able to yield useful results, as there are so many function calls happening, that the function call overhead by the profiler is more visible then the actual php-cs-fixer workload.
after this PR, as we have less function calls, profiles get a bit more precise. tbh we should do a few more optimizations to bring the tooling into a state where it can be helpful for us.