mattwil         Fri May 30 10:54:17 2008 UTC

  Modified files:              
    /php-src/ext/standard       array.c 
  Log:
  Only check args once in php_array_diff_key/intersect_key, not on each 
iteration. This also makes sure ALL args are checked (pre-5.2.5 behavior)
  - Also, use new hash_quick_del function where possible
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.451&r2=1.452&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.451 php-src/ext/standard/array.c:1.452
--- php-src/ext/standard/array.c:1.451  Tue May 27 10:28:25 2008
+++ php-src/ext/standard/array.c        Fri May 30 10:54:16 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.451 2008/05/27 10:28:25 mattwil Exp $ */
+/* $Id: array.c,v 1.452 2008/05/30 10:54:16 mattwil Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -2978,7 +2978,7 @@
                                if (Z_ARRVAL_P(return_value) == 
&EG(symbol_table)) {
                                        
zend_u_delete_global_variable(p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength 
- 1 TSRMLS_CC);
                                } else {
-                                       
zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), 
p->nKeyLength);
+                                       
zend_u_hash_quick_del(Z_ARRVAL_P(return_value), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h);
                                }
                        }
                }
@@ -3075,10 +3075,12 @@
                }
        }
 
-       if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument #1 is not 
an array");
-               RETVAL_NULL();
-               goto out;
+       for (i = 0; i < argc; i++) {
+               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument 
#%d is not an array", i + 1);
+                       RETVAL_NULL();
+                       goto out;
+               }
        }
 
        array_init(return_value);
@@ -3087,12 +3089,7 @@
                if (p->nKeyLength == 0) {
                        ok = 1;
                        for (i = 1; i < argc; i++) {
-                               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-                                       php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "Argument #%d is not an array", i + 1);
-                                       zval_dtor(return_value);
-                                       RETVAL_NULL();
-                                       goto out;
-                               } else if 
(zend_hash_index_find(Z_ARRVAL_PP(args[i]), p->h, (void**)&data) == FAILURE ||
+                               if (zend_hash_index_find(Z_ARRVAL_PP(args[i]), 
p->h, (void**)&data) == FAILURE ||
                                        (intersect_data_compare_func &&
                                        
intersect_data_compare_func((zval**)p->pData, data TSRMLS_CC) != 0)
                                ) {
@@ -3107,12 +3104,7 @@
                } else {
                        ok = 1;
                        for (i = 1; i < argc; i++) {
-                               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-                                       php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "Argument #%d is not an array", i + 1);
-                                       zval_dtor(return_value);
-                                       RETVAL_NULL();
-                                       goto out;
-                               } else if 
(zend_u_hash_quick_find(Z_ARRVAL_PP(args[i]), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h, (void**)&data) == FAILURE ||
+                               if 
(zend_u_hash_quick_find(Z_ARRVAL_PP(args[i]), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h, (void**)&data) == FAILURE ||
                                        (intersect_data_compare_func &&
                                        
intersect_data_compare_func((zval**)p->pData, data TSRMLS_CC) != 0)
                                ) {
@@ -3342,7 +3334,7 @@
                                        if (p->nKeyLength == 0) {
                                                
zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                                        } else {
-                                               
zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), 
p->nKeyLength);
+                                               
zend_u_hash_quick_del(Z_ARRVAL_P(return_value), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h);
                                        }
                                }
                        }
@@ -3358,7 +3350,7 @@
                                if (p->nKeyLength == 0) {
                                        
zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                                } else {
-                                       
zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), 
p->nKeyLength);
+                                       
zend_u_hash_quick_del(Z_ARRVAL_P(return_value), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h);
                                }
                                if (!*++ptrs[0]) {
                                        goto out;
@@ -3501,10 +3493,12 @@
                }
        }
 
-       if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument #1 is not 
an array");
-               RETVAL_NULL();
-               goto out;
+       for (i = 0; i < argc; i++) {
+               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument 
#%d is not an array", i + 1);
+                       RETVAL_NULL();
+                       goto out;
+               }
        }
 
        array_init(return_value);
@@ -3513,12 +3507,7 @@
                if (p->nKeyLength == 0) {
                        ok = 1;
                        for (i = 1; i < argc; i++) {
-                               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-                                       php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "Argument #%d is not an array", i + 1);
-                                       zval_dtor(return_value);
-                                       RETVAL_NULL();
-                                       goto out;
-                               } else if 
(zend_hash_index_find(Z_ARRVAL_PP(args[i]), p->h, (void**)&data) == SUCCESS &&
+                               if (zend_hash_index_find(Z_ARRVAL_PP(args[i]), 
p->h, (void**)&data) == SUCCESS &&
                                        (!diff_data_compare_func ||
                                        
diff_data_compare_func((zval**)p->pData, data TSRMLS_CC) == 0)
                                ) {
@@ -3533,12 +3522,7 @@
                } else {
                        ok = 1;
                        for (i = 1; i < argc; i++) {
-                               if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
-                                       php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "Argument #%d is not an array", i + 1);
-                                       zval_dtor(return_value);
-                                       RETVAL_NULL();
-                                       goto out;
-                               } else if 
(zend_u_hash_quick_find(Z_ARRVAL_PP(args[i]), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h, (void**)&data) == SUCCESS &&
+                               if 
(zend_u_hash_quick_find(Z_ARRVAL_PP(args[i]), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h, (void**)&data) == SUCCESS &&
                                        (!diff_data_compare_func ||
                                        
diff_data_compare_func((zval**)p->pData, data TSRMLS_CC) == 0)
                                ) {
@@ -3780,7 +3764,7 @@
                                if (p->nKeyLength == 0) {
                                        
zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                                } else {
-                                       
zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), 
p->nKeyLength);
+                                       
zend_u_hash_quick_del(Z_ARRVAL_P(return_value), p->key.type, 
ZSTR(p->key.arKey.s), p->nKeyLength, p->h);
                                }
                                if (!*++ptrs[0]) {
                                        goto out;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to