note 95125 deleted from class.splfixedarray by colder
| From: | colder@php.net | Date: | Sat, 18 Feb 2012 01:00:14 +0000 |
| Subject: | note 95125 deleted from class.splfixedarray by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-186203@lists.php.net to get a copy of this message | ||
Note Submitter: randallgirard at hotmail dot com
----
NOTE: This only affects CREATION time, NOT access time.
It does NOT create a true indexed array (which is what I was hoping for) but is still associative
like all PHP arrays. The class requires a numeric key because it builds the array with a set number
of items but still operates under the hood associatively. (or this is my assumption, as I performed
benchmarks comparing 100,000 reads on a standard array and an SplFixedArray: Results were the same,
while a true indexed array SHOULD in theory be faster than an associative)
The only performance gain is that you are not building the array piece by piece; Rather, the entire
array is built at once and you can then fill it's values by numeric indexes... Therefor it is
only reducing the creation overhead.
This is only useful in a situation when you know the size your array will be, for example filling it
with items from a database query.