-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Prefix global functions #1103
Comments
AFAIK this optimization is only relevant for a subset of native PHP functions, see PHP-CS-Fixer/PHP-CS-Fixer#3048 (comment) and PHP-CS-Fixer/PHP-CS-Fixer#3048 (comment) IMO we should only activate |
Yes, I was just about to comment the same. Let's wait for a decision there and use the fixer like we already do now. |
I have prefixed our function calls manually with an adjusted version of the fixer in 941b81d. I'll leave the ticket open until the fixer has been adjusted. I haven't changed the legacy code, although there are a lot of function calls in it as well. How do we handle this? |
We should enable the
NativeFunctionInvocationFixer
in the php-cs-fixer in the develop branch so all our global functions are prefixed by\
. So instead of using e.g.is_object()
we should use\is_object()
. This will give us quite a performance boost because for global functions, the PHP engine can trigger additional optimizations when using opcode. E.g. if we use\in_array()
withtrue
as third parameter and the array is static, it doesn't have to evaluate over and over again but instead opcode will cache the result.I didn't test it at all but I expect some pretty notable performance gains.
More info: https://veewee.github.io/blog/optimizing-php-performance-by-fq-function-calls/
The text was updated successfully, but these errors were encountered: