chakra-core / chakra-core/ChakraCore

Abstract iterable loop in built-in constructors to reduce down to one implementation that contains special case optimization for arrays

Open
#571 1 comment 0 reactions 1 assignee Assigned to @akroshg View on GitHub
Suggestion
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

This is an idea I got from code reviewing #561.

There are numerous built-in constructors that optionally construct from a passed in iterable. In all of these constructors we could special case arrays so long as `Array.prototype[Symbol.iterator]` hasn't changed (or rather, the `[Symbol.iterator]` property on the given object is pointing to the array built-in value, and the object is itself an array).

It might be possible without complication to pull this common construct-from-iterable pattern out into a generic loop-over-iterable function that takes a lambda function for action on each element, and then implements the special case paths for arrays (and perhaps the other built-ins iterables Map, Set, and String).

This could also be applied to other loops over iterables in the runtime.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.