Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 1, 2025

I imagine theses usages of forEach predated the use of for..of in our codes and the for..in loops were more clumsy.

Using simple for loops here is generally faster at runtime and simpler to reason about (since return is not needed in place of continue and the binding of this is not hard to reason about, its just the same as the surrounding code).

Its also a codesize win.

@sbc100 sbc100 requested a review from kripken November 1, 2025 03:52
@sbc100 sbc100 requested a review from juj November 1, 2025 04:03
@sbc100 sbc100 force-pushed the forEach branch 2 times, most recently from 5ce00cc to cac7391 Compare November 1, 2025 05:41
I imagine theses usages of `forEach` predated the use of `for..of`
in our codes and the `for..in` loops were more clumsy.

Using simple `for` loops here is generally faster at runtime and simpler
to reason about.
@sbc100 sbc100 enabled auto-merge (squash) November 2, 2025 01:00
Copy link
Collaborator

@juj juj left a comment

Choose a reason for hiding this comment

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

Very nice, highly approve.

@sbc100 sbc100 merged commit 7569d8e into emscripten-core:main Nov 3, 2025
34 checks passed
@sbc100 sbc100 deleted the forEach branch November 3, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants