Compiler Optimizations
| From: | Chase Peeler | Date: | Tue, 15 Sep 2020 13:23:05 +0000 |
| Subject: | Compiler Optimizations | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-111862@lists.php.net to get a copy of this message | ||
I brought this up on another thread, but it wasn't addressed (which is
fine, since it was somewhat off-topic). I thought it might be
worth bringing up in its own thread, though.
In the other thread, someone had mentioned the following compiler
optimization
foreach(\array_keys($arr) as $key) {
and quietly transform that into:
foreach ($arr as $key => $_unusedVariableNameThatIsntEvenSpilledToTheScope)
{
I would be more likely to write:
$keys = array_keys($arr);
foreach($keys as $key){
Which would prevent me from being able to take advantage of the
optimization.
So, what I was wondering, is if there are other optimizations I might be
missing out on, and if so, are they documented anywhere?
--
Chase Peeler
chasepeeler@gmail.com