Skip to content

Use destructuring for timeOrigin in emscripten_get_now. NFC - #28286

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:timeorigin-followup
Nov 17, 2026
Merged

sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:timeorigin-followup

Conversation

@sbc100

@sbc100 sbc100 commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Apply followup feedback from #28272 in src/lib/libcore.js. Use const {timeOrigin} = performance; instead of var so Closure Compiler lowers it to let rather than a hoisted var and destructuring assignment, saving bytes both with and without Closure.

See: #28272

Apply followup feedback from emscripten-core#28272 in `src/lib/libcore.js`. Use
`const {timeOrigin} = performance;` instead of `var` so Closure
Compiler lowers it to `let` rather than a hoisted `var` and
destructuring assignment, saving bytes both with and without Closure.

See: emscripten-core#28272
@sbc100 sbc100 changed the title Use destructuring for timeOrigin in emscripten_get_now Use destructuring for timeOrigin in emscripten_get_now. NFC Nov 17, 2026
@sbc100
sbc100 requested a review from RReverser November 17, 2026 16:13

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the retrieval of performance.timeOrigin in src/lib/libcore.js to use object destructuring. The reviewer suggests providing a default value of 0 during destructuring to prevent potential NaN values if performance.timeOrigin is undefined in certain environments.

Comment thread src/lib/libcore.js Resolved
@RReverser

Copy link
Copy Markdown
Collaborator

saving bytes both with and without Closure

Did you run update sizes?

@sbc100

sbc100 commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

saving bytes both with and without Closure

Did you run update sizes?

Yes, a few bytes, but we don't have any codesize tests that cover pthreads + audio worklets, which is where this code lives.

@sbc100
sbc100 merged commit 303f064 into emscripten-core:main Nov 17, 2026
43 checks passed
@sbc100
sbc100 deleted the timeorigin-followup branch November 17, 2026 18:01
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 17, 2026
Followup to emscripten-core#28286

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Also update `src/jsifier.mjs` arrow-function detection so top-level JS
library arrow functions with destructured parameters (containing `}`)
are recognized and emitted properly.

Update affected `test/codesize/` expectations.

See: emscripten-core#28272
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 17, 2026
Followup to emscripten-core#28286

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Also update `src/jsifier.mjs` arrow-function detection so top-level JS
library arrow functions with destructured parameters (containing `}`)
are recognized and emitted properly.

Update affected `test/codesize/` expectations.

See: emscripten-core#28272
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 18, 2026
Followup to emscripten-core#28286

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Update affected `test/codesize/` expectations.

See: emscripten-core#28272
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 18, 2026
Followup to emscripten-core#28286

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Update affected `test/codesize/` expectations.

See: emscripten-core#28272
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 23, 2026
Followup to emscripten-core#28286

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Update affected `test/codesize/` expectations.

See: emscripten-core#28272
sbc100 added a commit that referenced this pull request Nov 23, 2026
Followup to #28286
Depends on #28288

Use object and parameter destructuring for multi-property reads and
unused event parameters across `src/lib/` and
`src/pthread_esm_startup.mjs`, using `const` for declarations so
Closure Compiler lowers them cleanly without extra bindings.

Update affected `test/codesize/` expectations.

See: #28272
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