-
Notifications
You must be signed in to change notification settings - Fork 7.9k
zend_closures.c: Call closure directly #17372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This prevents a bunch of indirection and calling a C function via a function pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is avoiding a call to zend_is_callable_ex()
? Is this measurably faster?
if (call_user_function_named(CG(function_table), NULL, ZEND_THIS, return_value, num_args, args, named_args) == FAILURE) { | ||
RETVAL_FALSE; | ||
} | ||
zend_fcall_info_cache fcc = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This causes some unnecessary initialization or most fields that are set later. It's probably elided if zend_closure_get_closure()
is inlined though.
Basically yes as the current call does the following:
I did not measure if this is faster or not, as I'm trying to rely less on the Another reason is that this is the only reference to I could also just inline (note to self, I should update https://www.phpinternalsbook.com/php7/internal_types/functions/callables.html or move it to the new php-src internal docs as some stuff has changed since I wrote this) |
A quick benchmark would be good when touching performance critical code. Sometimes performance changes unexpectedly. |
What sort of benchmark do you want me to run? I also don't see how this could possibly be slower than the existing indirections. |
I see this is only called when doing |
This prevents a bunch of indirection and calling a C function via a function pointer