Skip to content

Only use 'es2015.iterable' to avoid accidental es2015 feature usage. #28951

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 11, 2018

Conversation

DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Dec 11, 2018

Fixes #28933.

@j-oliveras
Copy link
Contributor

Fixes #28933.

@@ -2165,6 +2165,10 @@ namespace ts {
}

export function fill<T>(length: number, cb: (index: number) => T): T[] {
return new Array(length).fill(0).map((_, i) => cb(i));
const result = Array<T>(length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in V8 this causes the array to be considered "holey" and therefore it's not as optimized as packed arrays.
On the other hand repeatedly calling push needs to grow the backing store.

I'd say this is fine as is, as this function is only used in a single place in generateTypes.ts. So the holey array won't cause too much deoptimization where it's used. The alternative using push wouldn't be a problem either because the arrays are unlikely to contain more than a dozen elements.

@DanielRosenwasser DanielRosenwasser merged commit 5ab24ed into master Dec 11, 2018
@DanielRosenwasser DanielRosenwasser deleted the fixLibToIterableAndES5 branch January 18, 2020 03:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants