Add Closure::fromCallable().#1906
Conversation
Add the ability to create closures from callable as part of RFC: https://wiki.php.net/rfc/closurefromcallable
|
|
||
|
|
||
| /* {{{ proto Closure Closure::fromCallable(callable callable) | ||
| Create a closure from a callabl using the current scope. */ |
| memset(&call, 0, sizeof(zend_internal_function)); | ||
|
|
||
| call.type = ZEND_INTERNAL_FUNCTION; | ||
| call.handler = zend_closure_call_magic; |
There was a problem hiding this comment.
Call through zend_call_function() is more expensive than through TRAMPOLINE.
Why it's not possible to reuse the same trampoline?
May be it makes sense to move trampoline function into zend_closure and free it together with closure object...
There was a problem hiding this comment.
Dmitry - I don't really understand trampolines. So long as this PR is acceptable and the tests all pass, is it okay for you to do any performance improvements you think are good, after this PR is accepted and closed?
There was a problem hiding this comment.
Yeah. Commit this. I'll take a look, if it's possible to optimise this using trampolines later.
| @@ -0,0 +1,48 @@ | |||
| --TEST-- | |||
| Imagick::readImage test | |||
|
Can someone tag this with RFC and accepted, it is destined for 7.1. |
Add the ability to create closures from callable as part of RFC: https://wiki.php.net/rfc/closurefromcallable