diff options
| author | Jeroen van Wolffelaar <jeroen@php.net> | 2001-10-05 21:58:41 +0000 |
|---|---|---|
| committer | Jeroen van Wolffelaar <jeroen@php.net> | 2001-10-05 21:58:41 +0000 |
| commit | 62feefddc725f1948636fd47c647d8c9bf55b4bc (patch) | |
| tree | 60b938a3e439a338ea6cf3fc9728ad2bb11f142b /ext | |
| parent | 89ea50a58843076b1831a90d8813cf4c51d8fde9 (diff) | |
| download | php-git-62feefddc725f1948636fd47c647d8c9bf55b4bc.tar.gz | |
Fix array_search and in_array. Now binary safe, and faster (returns when
found, and doesn't duplicate the key each time, but only when necessary)
Patch also by Edin Kadribasic
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/standard/array.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 922f9cf3b9..a6cea5e699 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1042,6 +1042,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) HashTable *target_hash; /* array hashtable */ HashPosition pos; /* hash iterator */ ulong num_key; + uint str_key_len; char *string_key; int (*compare_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; @@ -1076,12 +1077,12 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) RETURN_TRUE; } else { /* Return current key */ - switch (zend_hash_get_current_key_ex(target_hash, &string_key, NULL, &num_key, 1, &pos)) { + switch (zend_hash_get_current_key_ex(target_hash, &string_key, &str_key_len, &num_key, 0, &pos)) { case HASH_KEY_IS_STRING: - RETVAL_STRING(string_key, 0); + RETURN_STRINGL(string_key, str_key_len-1, 1); break; case HASH_KEY_IS_LONG: - RETVAL_LONG(num_key); + RETURN_LONG(num_key); break; } } |
