- π©πͺGermany donquixote
Note:
As of the question of Closure::fromCallback: See the RFC, it is said that converting a callback (function name, class/method array) to a closure, statically caching it and using this multiple times has significant performance gains. We can leave that to a followup though.
The important part here is "statically caching it and using this multiple times".
But this is exactly NOT what we are doing.
A new closure is created in every iteration and every call, and never cached.
And even if we would cache it, it would only pay off if the same hook is called multiple times in the same request. So we would have to know how many times a hook is called on average.Now we cannot really go back, because there could be contrib or custom modules out there that call ->invokeAllWith with a callback argument that expects a Closure instead of callable.
// this would break if we pass a callable-string. $mh->invokeAllWith('some_hook', static function (\Closure $impl) {..}); // this will work if we pass a callable-string. $mh->invokeAllWith('some_hook', static function (callable $impl) {..});
- π«π·France andypost
Re #146 let's continue optimizations in one of following issues
- #329012-107: Remove call_user_func_array() from ModuleHandler::invoke() + invokeAll() β
- π Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...) Needs work