cvs: php4 /ext/standard array.c

From: Date: Fri, 05 Oct 2001 21:58:41 +0000
Subject: cvs: php4 /ext/standard array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-7685@lists.php.net to get a copy of this message
jeroen Fri Oct 5 17:58:41 2001 EDT Modified files: /php4/ext/standard array.c Log: 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 Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.139 php4/ext/standard/array.c:1.140 --- php4/ext/standard/array.c:1.139 Fri Oct 5 16:14:33 2001 +++ php4/ext/standard/array.c Fri Oct 5 17:58:41 2001 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.139 2001/10/05 20:14:33 jeroen Exp $ */ +/* $Id: array.c,v 1.140 2001/10/05 21:58:41 jeroen Exp $ */ #include "php.h" #include "php_ini.h" @@ -1042,6 +1042,7 @@ 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 @@ 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; } }

« previous php.cvs (#7685) next »