Marcus,
From reading this it doesn't seem as if this patch is array() specific but is a general one.
If I understand correctly, it will pass the hash (zval *) as-is and will never do a zval_copy_ctor(). This means that this value must for all practical purposes be read-only. What does this mean to the extension writer?
Am I correct? We need to be sure that we don't add this new functionality without being sure how the extensions should handle it in order not to get side effects.
Andi
At 12:20 PM 10/2/2004 +0200, Marcus Boerger wrote:
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
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php