Re: [PATCH] array_combine is not binary-key safe

From: Date: Sun, 23 Jul 2006 17:29:27 +0000
Subject: Re: [PATCH] array_combine is not binary-key safe
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-24912@lists.php.net to get a copy of this message
Most compiler (I know gcc and Visual C do) will optimize strlen("static_string"). On 21-Jul-06, at 9:04 AM, Matt W wrote:
Hi Richard, I think I've seen those instances that you're referring to. By fixed length string I assume you mean hard-coded "string_key". Yeah, I would think those should use add_assoc_*_ex() since the length is known (sizeof("string_key") etc.) to save unnecessary strlen() calls. Unless compilers optimize the strlen("string_key") + 1 to a constant from the add_assoc_*() macro. But I wouldn't think that's the case...? :-/ Matt ----- Original Message ----- From: "Richard Quadling" Sent: Friday, July 21, 2006
Hi, There are 46 uses of add_assoc_zval() in the CVS. Many are with fixed length strings for the key. Should the others all be using add_assoc_zval_ex() ? On 21/07/06, Matt W <php_lists@realplain.com> wrote:
Hi, I don't know if array_combine() was intentionally made binary-key
unsafe,
but it seems wrong and inconsistent since binary keys work everywhere
else I
can think of -- including array_flip() and the new array_fill_keys().
And
updating it is a bit of an optimization by eliminating strlen() calls.
:-)
I also changed the error message to be more grammatically-correct and
fixed
some typos in the description. http://www.realplain.com/php/array_combine_binkey.diff http://www.realplain.com/php/array_combine_binkey_5_2.diff Thanks, Matt
--PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Ilia Alshanetsky

« previous php.internals (#24912) next »