Add fast paths for class/style string arguments in BlazeAttributeBag#168
Add fast paths for class/style string arguments in BlazeAttributeBag#168SanderMuller wants to merge 1 commit intolivewire:mainfrom
Conversation
|
/benchmark class |
|
/benchmark merge |
Benchmark Result: Class
Median of 10 attempts, 5000 iterations x 10 rounds, 31.77s total To run a specific benchmark, comment |
Benchmark Result: Merge
Median of 10 attempts, 5000 iterations x 10 rounds, 23.32s total To run a specific benchmark, comment |
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 45.63s total To run a specific benchmark, comment |
|
Looks like this causes an attribute ordering issue in the FluxPro tests (you would need to dev-require Flux Pro with a valid license to run these): Tests\FluxProTest > chart: - <ui-chart wire:model="data" class="block [:where(&)]:relative w-full aspect-2/1" wire:ignore.children >
+ <ui-chart class="block [:where(&)]:relative w-full aspect-2/1" wire:model="data" wire:ignore.children >Alternatively feel free to add a separate comparison test for this |
When merge(), class(), or style() receive a simple string argument (the most common usage), skip the general-purpose loops and handle the merge directly. The shared class-merging logic is extracted into withMergedClass() to avoid duplication between merge() and class(). Uses array union to place the merged key first, matching the attribute ordering of the general merge() path's array_merge($defaults, $attrs). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
22dea7d to
c7e51ea
Compare
Thanks. I do have a Flux Pro license, but figured it would be good to have a CI test so I took the option to add a test for it (and make the code pass it) |
When
merge(),class(), orstyle()receive a simple string argument (the most common usage), skip the general-purpose loops and handle the merge directly.The shared class-merging logic is extracted into
withMergedClass()to avoid duplication betweenmerge()andclass().This replaces both PR #157 and #161 with a single combined PR.