AFAICS, it should make every local-variable (non-global) lookup slower. Since it needs to do a lookup in the globals table first.

Xuefer Tinys wrote:
$_GET is solved at compile time, which is good, but this make other
variables bad at execution time?

how much does this patch slow execution down? it's one more hash lookup.
affect speed of $var or $$var? or both?


On Mon, 31 Jan 2005 14:24:41 -0800, Sara Golemon <[EMAIL PROTECTED]> wrote:

So in order for ZE to resolve the autoglobals correctly during runtime it
has to ask two questions for every *part* of every variable resolution:

"Are

we checking against the active symbol table? Is the index we're looking

for

in the autoglobal registry?"  If so, replace active_symbol_table with the
global symbol_table, otherwise do the lookup as normal.


I knew this statement felt wrong when I wrote it so I dove in and looked at the code again....It's not actually necessary to test the what scope we're in because of the way the parser is laid out... however it does still add an extra hashtable lookup that shouldn't be necessary, so my original position stands as is for now.

If someone would like to benchmark the following patch (Or point out any
fatal flaws in it) I'd be interrested in the results, but even if there's no
perceptible difference over a million itterations, I'd probably still
vote -1 on changing it.

-Sara

Index: Zend/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.692
diff -u -r1.692 zend_execute.c
--- Zend/zend_execute.c 22 Jan 2005 02:29:18 -0000      1.692
+++ Zend/zend_execute.c 31 Jan 2005 22:13:50 -0000
@@ -1001,6 +1001,10 @@
{
      switch (opline->op2.u.EA.type) {
              case ZEND_FETCH_LOCAL:
+                       if (zend_hash_exists(CG(auto_globals),
variable->value.str.val, variable->value.str.len + 1)) {
+                               /* Dynamically resolved auto global */
+                               return &EG(symbol_table);
+                       }
                      return EG(active_symbol_table);
                      break;
              case ZEND_FETCH_GLOBAL:

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to