On 04-01-2010 at 14:40:13 Iván Montes <drsl...@pollinimini.net> wrote:

Yeah, I thought about using LimitIterator [1] to avoid the creation of temporary arrays but I wasn't sure about the performance of it (does it always seek?) or if it works with Traversables.

Documentation says it doesn't (constructor requires Iterator interface).

I'd also expect it to always seek (for non-zero offset), because Iterator interface can't report current iteration position.

A custom "LimitIterator", without seeking, might of course work, or perhaps it's enough to just modify the code and use a SplFixedArray object to ensure constant memory usage, without relying on PHP's garbage collector to do the job.

By constant I meant not dependent on the size of iterated data. Unless I misunderstood, SplFixedArray would still depend on size of data, e.g. it wouldn't let you generate 100MB large document on PHP with 10MB memory limit, which hopefully is possible with echoExecute() and non-buffering iterators.

--
regards, Kornel

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to