Skip to content

[perf] Speed up CodingStyle rules with cheap guards before type lookup, reflection and regex - #8669

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-cs-cheap-guard-before-type-regex
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-cs-cheap-guard-before-type-regex

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Performance refactor of 3 rules. No behavior change - all fixtures pass unchanged.

  • StrictInArrayRector - the first argument native type is now resolved only after the second argument is confirmed to be an array, so a non-array second argument skips one getNativeType() call.
  • UseClassKeywordForClassNameResolutionRector - the cheap str_contains($name, "\\") check now runs inside getExistingClasses() before reflectionProvider->hasClass(), so short non-namespaced matches skip the reflection lookup. The separate filterOurShortClasses() pass that removed them afterwards is now redundant and removed.
  • SimplifyQuoteEscapeRector - a string with no quote characters now bails before hasNonPrintableChars() (two regex matches plus a unicode check), using the already-computed substr_count() values.

Reordering is safe: all moved checks are side-effect-free bail conditions, and the removed filter was the only consumer of the short-name exclusion it duplicated.

@TomasVotruba
TomasVotruba merged commit bc1fc69 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-cs-cheap-guard-before-type-regex branch October 15, 2026 21:34
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