-
Notifications
You must be signed in to change notification settings - Fork 10
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
Why is js() a function instead of a variable? #5
Comments
Two reasons offhand:
If you find actual performance differences/issues with the use of such a constant function, I'd be interested in seeing them. |
In Firefox the variable is almost three times faster than function call, in Safari and Opera - almost twenty times faster. Or am I doing the test wrong? :) |
I just verified similar results with your test on my MacBook Air 11". That's quite the difference. Ok, will consider a change like this for v0.2 (working hard to wrap up last changes for v0.1). In particular I may use a slightly longer name (maybe $in_js) for the global variable to reduce likelihood of collision. |
I don't think this will work as a variable, since in PHP, global variables must be declared at the beginning of the function. For example, in order for a function to be able to see the
The advantage of using the |
Just switched to returning true or false depending on which comment-code path so that should be even faster (for any modern js jit / or PHP processors). |
Shouldn't this:
be replaced with this:
This way, there would be less function calls and the "00"==false expression would only be evaluated once per script run.
The text was updated successfully, but these errors were encountered: