History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-2090
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Matthew Weier O'Phinney
Reporter: Lars Strojny
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

More efficient differentiation between structs and arrays

Created: 21/Oct/07 04:50 PM   Updated: 21/Mar/08 06:50 PM  Due: 20/Mar/08
Component/s: Zend_XmlRpc_Client
Affects Version/s: 1.5.0RC1
Fix Version/s: 1.5.1

Time Tracking:
Original Estimate: 2 hours
Original Estimate - 2 hours
Remaining Estimate: 2 hours
Remaining Estimate - 2 hours
Time Spent: Not Specified
Remaining Estimate - 2 hours

File Attachments: 1. Text File array_vs_hash-more-efficient.diff (1 kb)
2. File benchmark.php (1 kb)


 Public Fields   Internal Project Management Fields   
Tags:
Participants: Lars Strojny and Matthew Weier O'Phinney
Fix Version Priority: Must Have


 Description  « Hide
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.

 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Matthew Weier O'Phinney - 16/Nov/07 03:05 PM
Scheduling for 1.0.3

Matthew Weier O'Phinney - 26/Nov/07 10:18 AM
Updated and pushed to release branch as of r6938.

Lars Strojny - 03/Dec/07 06:43 PM
I'm sorry, but you change made it even worse. I attached a benchmark between our two strategies to differentiate.

Lars Strojny - 03/Dec/07 06:44 PM
Here is my result:
array_reduce(): 1.23774003983
count()/range(): 0.39503288269

Matthew Weier O'Phinney - 06/Mar/08 10:14 AM
Scheduling for 1.5.0RC2

Matthew Weier O'Phinney - 06/Mar/08 08:00 PM
Applied in trunk and 1.5 release branch

Matthew Weier O'Phinney - 17/Mar/08 01:17 PM
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.


Matthew Weier O'Phinney - 21/Mar/08 11:24 AM
Fix committed in trunk in r8953 and in release-1.5 branch in r 8954. This should resolve all issues at this point.