Hello internals,

Hello Andi,

  here's another major speed improvement for array functions which
is probably also valid for other functions, too. The point is that
we have several functions not forcing parameters by reference because
they not only accept variables but also parameters by value and we
cannot pass values by ref directly. The solution is to automatically
find out whether to pass by ref or not. See the test script for
the difference - it's amazing in this example!

http://php.net/~helly/php/ext/ze2/ze2-auto-ref-20040930.diff.txt
http://php.net/~helly/php/ext/ze2/ze2-auto-ref.php

How does it work exactly:

For example the function in_array() is defined with both arg types == 0
which mean not by ref. As a consequence when you have an array which is
stored somewhere else as a reference it will be copied. So the obvious
question is why not declare the function arg type as force by reference?
Simply because that does not work. The array functions are all designed
to accept arrays on the fly like in_array(2,array(1,2)). And unfortunatley
those direct values cannot be send by reference. But the compiler knows
whether it can send by ref or not and that is what the patch does. It
adds a new argument infor which tells the compiler to find out whether
the parameter can be passed by reference or must be passed by value.

Any comments?

-- 
Best regards,
 Marcus

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

Reply via email to