Re: Request for couple memory optimized array improvements
| From: | Michael Voříšek - ČVUT FEL | Date: | Mon, 31 Aug 2020 21:39:19 +0000 |
| Subject: | Re: Request for couple memory optimized array improvements | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111753@lists.php.net to get a copy of this message | ||
I would highly prefer php optimalization for it. ArrayKeysIterator can
not even used if the input is iterable instead of pure array.
With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
Michael Voříšek
On 31 Aug 2020 23:31, Max Semenik wrote:
On Mon, Aug 31, 2020 at 11:53 PM Michael Voříšek - ČVUT FEL <vorismi3@fel.cvut.cz> wrote:Optimizing foreach (array_keys($arr) as $k) is very important, not only because of memory, but because of speed when not all elements needs to be iterated, like: foreach (array_keys($arr) as $k) { if ($k some condition) { break; } }Can an iterator be the answer? E.g. foreach (new ArrayKeysIterator($arr) as $k) { ... } -- Best regards, Max Semenik