Repository navigation
[perf] Replace isStringName wildcard loop with single strpbrk scan - #8733
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a non-matching name - the common case, since a rule tests
isName()against many candidates and most fail -isStringName()falls through to a guard that rejects leftover regex/fnmatch patterns. It scanned the needle once per wildcard char via aforeach+str_contains; a singlestrpbrk()over the same char set does it in one C-level pass.Behaviour is identical:
strpbrk()returns non-false when any of* # ~ /is present, exactly when the old loop threw. The array const became a string const (its only use was the loop). An in-process profile rankedisStringNameat ~32M self cost over 164k calls - the busiest Rector-owned function in the run.Micro A/B (bench/node_name_resolver_is_string_name_bench.php, 200k calls x 60 repeats, PHP 8.4, CPU user+sys):
Run on both branches to compare: