Re: [PHP-DEV] array_filter vs for/foreach usage cost

This is only part of a thread. view whole thread
September 7, 2017 19:13 (Sara Golemon)
On Thu, Sep 7, 2017 at 2:13 PM, David Rodrigues> wrote:
> I understand that array_filter() should costs more than for/foreach because > it is a function call that call another function for each item, while the > for/foreach is a language constructor that works on a way totally different > and its optimized for this kind of job. > What you're describing is called inlining. At the moment, the main
barrier to inlining is the symbol scopes. 1. Any variables used within the closure must not collide with the calling scope unless: 1.a: The value is captured by ref, or 1.b: The value has been captured by val and is reset between invocations. 2. Variables within the closure must destruct at the end of each invocation (loop). If you're seriously interested, I'd recommend prototyping an optimizing using the zend_ast_process hook. -Sara