Reduce per-call overhead for self-closing components#162
Reduce per-call overhead for self-closing components#162SanderMuller wants to merge 2 commits intolivewire:mainfrom
Conversation
Benchmark Result: Attributes
Median of 10 attempts, 5000 iterations x 10 rounds, 22.98s total To run a specific benchmark, comment |
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 33.28s total To run a specific benchmark, comment |
|
Love the And I'm almost certain removing pushData would break things, flux:delegate-component uses the data stack and could be used inside another component without slots. Can we double check this? |
Thanks for the feedback, I'm looking into it |
cf0677a to
ebd6577
Compare
Use function_exists() guard instead of calling ensureRequired() on every render. After the first render, function_exists() is a C-level check that's faster than a PHP method call + hash table lookup. Also adds a test verifying that self-closing components correctly propagate data to @AWare descendants via the data stack. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ebd6577 to
4b96d2b
Compare
You were right about the pushData breaking change. I've added a failing test to prevent this regression in the future. And I think the if/else is quite large here, so early return can be nice, however I agree that it makes the diff in this PR hard to read, so I've reverted it to the if/else structure, which indeed helps a lot to review this change :) |
|
Nice, thanks! Wondering if this shouldn't be inside |
Move the function_exists() check into ensureRequired() so both the compiled caller and resolve() benefit from the C-level guard. Drop the $required hash table which is now redundant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1bc8c94 to
d31efff
Compare
|
/benchmark attributes |
Yeah good idea, applied |
An optimization to the compiled caller output for self-closing components:
Use function_exists() guard instead of calling ensureRequired() on every render. After the first render, function_exists() is a C-level check that's faster than a PHP method call + hash table lookup.