Re: [RFC] Iteration tools

From: Date: Tue, 04 Nov 2008 13:35:57 +0000
Subject: Re: [RFC] Iteration tools
Groups: php.internals 
Request: Send a blank email to internals+get-41639@lists.php.net to get a copy of this message
"Marcus Boerger" <helly@php.net> wrote in message news:154582775.20081103164129@marcus-boerger.de... > Hello Ionut, > > some remarks about your proposal: > > 1) You can turn any array into a Traversable using > (Recursive)ArrayIterator. Though this solution is still slow. The issue is > that the c-level code needs to verify the current pointer every single time > it uses it and that means traversing the array from the beginning. That > said we might want to: > a) Optimize that for cases where we don't have to. Basically when nothing > else is pointing to the array (refcount==1) we know when the array can be > changed and do not have to verify it always. > b) provide a lower level array to traversable mechanism that operates on > the current pointer provided by the array itself. That way having no need > to verify that pointer at all. That would be nice. Just written some code todo a binary search on keys, using the ArrayIterator::seek(). It was either that or use array_keys() on potentially large array. Jared

« previous php.internals (#41639) next »