ZF-2090: More efficient differentiation between structs and arrays
Description
Instead of iterating over each key, array_keys() in combination with range() is much faster to determine wheither it is an array or a struct.
Instead of iterating over each key, array_keys() in combination with range() is much faster to determine wheither it is an array or a struct.
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-16T15:05:23.000+0000
Scheduling for 1.0.3
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-26T10:18:08.000+0000
Updated and pushed to release branch as of r6938.
Posted by Lars Strojny (lars) on 2007-12-03T18:43:26.000+0000
I'm sorry, but you change made it even worse. I attached a benchmark between our two strategies to differentiate.
Posted by Lars Strojny (lars) on 2007-12-03T18:44:23.000+0000
Here is my result: array_reduce(): 1.23774003983 count()/range(): 0.39503288269
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-06T10:14:12.000+0000
Scheduling for 1.5.0RC2
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-06T20:00:39.000+0000
Applied in trunk and 1.5 release branch
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-17T13:17:41.000+0000
This patch highlights a huge issue with array/struct detection.
With the patch applied, we now have a situation where passing an empty array to a field expecting an array now results in an invalid argument exception -- because the empty array is incorrectly detected as a struct.
Before the patch was applied, we had the opposite siutation: passing an empty array to a field expecting a struct resulted in an invalid argument exception, because the empty array was detected as an array.
I'm re-opening the ticket, as we need to do some detection in the client for empty arrays and cast them to the appropriate types.
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-21T11:24:44.000+0000
Fix committed in trunk in r8953 and in release-1.5 branch in r 8954. This should resolve all issues at this point.