com php-src: Use fast comparison function: ext/standard/array.c

From: Date: Mon, 21 Apr 2014 22:03:10 +0000
Subject: com php-src: Use fast comparison function: ext/standard/array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77321@lists.php.net to get a copy of this message
Commit: b886d9ce1eb92dcc79c157f046142b1cb5eee271 Author: Dmitry Stogov <dmitry@zend.com> Tue, 22 Apr 2014 02:03:10 +0400 Parents: 1f181c0f4cce794461bbbed3b580d7d0d0a63ee9 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b886d9ce1eb92dcc79c157f046142b1cb5eee271 Log: Use fast comparison function Changed paths: M ext/standard/array.c Diff: diff --git a/ext/standard/array.c b/ext/standard/array.c index 50d064f..6dada18 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1216,31 +1216,43 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ ulong num_idx; zend_string *str_idx; zend_bool strict = 0; /* strict comparison or not */ - int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za|b", &value, &array, &strict) == FAILURE) { return; } if (strict) { - is_equal_func = is_identical_function; - } - - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) { - is_equal_func(&res, value, entry TSRMLS_CC); - if (Z_LVAL(res)) { - if (behavior == 0) { - RETURN_TRUE; - } else { - if (str_idx) { - RETVAL_STR(STR_COPY(str_idx)); + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) { + is_identical_function(&res, value, entry TSRMLS_CC); + if (Z_LVAL(res)) { + if (behavior == 0) { + RETURN_TRUE; } else { - RETVAL_LONG(num_idx); + if (str_idx) { + RETVAL_STR(STR_COPY(str_idx)); + } else { + RETVAL_LONG(num_idx); + } + return; } - return; } - } - } ZEND_HASH_FOREACH_END(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) { + if (fast_equal_function(&res, value, entry TSRMLS_CC)) { + if (behavior == 0) { + RETURN_TRUE; + } else { + if (str_idx) { + RETVAL_STR(STR_COPY(str_idx)); + } else { + RETVAL_LONG(num_idx); + } + return; + } + } + } ZEND_HASH_FOREACH_END(); + } RETURN_FALSE; }

« previous php.cvs (#77321) next »