Skip to content

[perf] Bucket generic tags by name in AnnotationToAttributeRector - #8745

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-annotation-attr-bucket
Oct 20, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-annotation-attr-bucket

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follows the configurable-rule config-scan cleanup (#8734 … #8744). AnnotationToAttributeRector::processGenericTags() scanned the whole configured annotation list for every generic doc tag, running strtolower() on both sides per entry.

Bucket the list by lowercased tag once in configure() and look the tag up directly. The doctrine-annotation path (matchAnnotationToAttribute, hasClassName) keeps the flat list - it matches by resolved class name, not by tag string, so it is left as is.

Numbers

bench/annotation_to_attribute_generic_tag_bench.php (400 entries, 100 generic-tag methods, CPU time, same run):

us/call
before 259.0
after 20.8

Scales with configured-list size. Full rules-tests/Php80/Rector/Class_/AnnotationToAttributeRector (65 tests) green, PHPStan and ECS clean.

processGenericTags() scanned the whole configured annotation list for every generic doc tag, running strtolower() on both sides per entry. Bucket the list by lowercased tag once in configure() and look the tag up directly. The doctrine-annotation path (matchAnnotationToAttribute, hasClassName) keeps the flat list, as it matches by resolved class name, not tag string.

bench/annotation_to_attribute_generic_tag_bench.php (400 entries, 100 generic-tag methods): 259.0 -> 20.8 us/call.
@TomasVotruba
TomasVotruba merged commit be841cd into main Oct 20, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-annotation-attr-bucket branch October 20, 2026 20:11
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