Standard constants as part of the lexer
| From: | Robert Eisele | Date: | Mon, 20 Jun 2011 10:48:51 +0000 |
| Subject: | Standard constants as part of the lexer | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-53375@lists.php.net to get a copy of this message | ||
The constants true, false and null are used very often. Unfortunately, every
usage of either of these constants invokes a constant lookup. There is no
problem with this, constant lookups are fast, but I nevertheless implemented
these constants directly in the lexer to avoid these lookups. I'd be glad to
see this change in 5.4 as the performance enhancement would be a steal.
I've also added a new OP code to hard-code count() and strlen() which
improves the performance by ~800%. This is nice, but limits the usage of
count() and strlen() as method name - if no further changes will be made at
the parser. I would rather see a optimization for every function call in
5.4.x. I'll take a look at this soon, maybe I can provide a patch for this,
too.
What do you think about the constants optimization? Unfortunateley, I've
broken the power cable of my macbook and have to wait for a new one. I'll
deliver in addition the patch if you like the idea.
Robert