Re: How to correctly spec sequences requiring an iterable

On Mon, Nov 18, 2013 at 10:53 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 11/18/13 1:45 PM, Tab Atkins Jr. wrote:
>>
>> As noted in the threads about iterators, engines should be able to
>> optimize this away in common cases, like a for-of loop.
>
> Sort of.  Optimizing it away requires special-case code that's pretty
> fragile and non-trivial.  I have no current plans to write such code for
> WebIDL sequences, fwiw.  We'll see how I feel once I measure the resulting
> performance.

One thing that very well might be worth optimizing is when a function
is passed a "plain" Array as the iterable. We'd of course have to
detect that no custom iterator or custom numeric getters are
installed. But if we know that's the case then we can probably
optimize iteration considerably.

I would expect that this is an optimization that the JS engine is
interested in doing internally too, for things like Array.concat etc.

/ Jonas

Received on Monday, 18 November 2013 20:12:29 UTC