[PATCH] No runtime fetching of built-in global constants
| From: | Matt Wilmas | Date: | Fri, 18 Apr 2008 14:26:22 +0000 |
| Subject: | [PATCH] No runtime fetching of built-in global constants | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-37134@lists.php.net to get a copy of this message | ||
Hi all,
I changed things so that the many "built-in" constants (CONST_PERSISTENT
ones) will be replaced at compile-time, saving the FETCH_CONSTANT opcode, if
these changes are usable. This was added for TRUE/FALSE/NULL 2 years ago,
but seems like it can be done for "lots" of others too.
Since the change 2 years ago, other constants have been getting looked up
also, but just discarded. And if a constant wasn't found, its name was
lowercased and looked up again (for case-insensitive TRUE/FALSE/NULL).
Lowercasing has been removed, since case-insensitive constants can't be done
(guess an exception was made for TRUE/FALSE/NULL :-)), and TRUE/FALSE/NULL
get flagged in the scanner (not reserved words, which Marcus did briefly a
few years ago), skipping a hash lookup. BTW, to get this compile-time
optimization in a namespace, it needs to be prefixed (::CONSTANT).
I also removed an unnecessary memcmp() in zend_get_constant() -- old code
that was needed a long time ago, it appears.
http://realplain.com/php/const_ct_optimization.diff
http://realplain.com/php/const_ct_optimization_5_3.diff
Thoughts?
Thanks,
Matt