Re: [PATCH] Bug #45877: LONG_MAX/MIN array key as string/int

From: Date: Mon, 23 Mar 2009 14:16:37 +0000
Subject: Re: [PATCH] Bug #45877: LONG_MAX/MIN array key as string/int
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-43436@lists.php.net to get a copy of this message
Hi Matt, Matt Wilmas wrote:
Hi Dmitry, While updating my version (more below), I noticed another problem that I overlooked before with your leading zero check: "-0" is being treated as numeric.
Yeah. Thank you for catching this. It should be fixed.
----- Original Message ----- From: "Dmitry Stogov" Sent: Friday, March 20, 2009
Hi Matt, I ran you version but it looked little bit slower (I checked it with callgrind). So I kept the current CVS version. Anyway, it is not a big problem to change it after RC.
Yeah, after I sent that message, I noticed other times were strange (bench.php, etc.), so it looks like I was getting compiler weirdness with that code layout... And of course looking at the code, there shouldn't have been anything faster about it, though it was shorter, which you confirmed with callgrind. Anyway, my updated version seems good, still smaller, and should do better with callgrind. :-) On 32-bit, the first digit of a 10 digit number can be checked which avoids having "2x overflow" on "5000000000", etc. that I pointed out with your original code. (No problem on 64-bit.) Also made the terminating null check be last again since it's least likely to fail... http://realplain.com/php/handle_numeric.txt OLD: http://realplain.com/php/handle_numeric-v1.txt
It looks like now your version must be better. Are you sure that it can't miss overflow? Can it be proved? Thanks. Dmitry.
Thanks. Dmitry.
- Matt


« previous php.internals (#43436) next »