cakephp/cakephp — pull request #2565 by lorenzo (2013-12-28 23:28:51+00:00)
Title: Adding Collection::compile as a way to optimize operations with a single collection

After the talk in IRC about streaming results I thought it would be nice to consolidate all results from an internal iterator into another collection. Also, I realized that by nesting iterators there would be a chance of wasting CPU by calculating stuff twice if the same variable is used.

This introduces `Collection::compile()`, a way of copying the results of toArray() from a collection into a new one in order to consolidate internal operations and to easily make iterators that would not rewind, rewindable