Skip to content

Commit b435a7c

Browse files
authored
Micro-optimize emscripten_get_now. NFC (#22592)
1 parent 6cfab10 commit b435a7c

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/library.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,14 +1428,14 @@ addToLibrary({
14281428

14291429
emscripten_random: () => Math.random(),
14301430

1431-
emscripten_get_now: `;
14321431
#if PTHREADS && !AUDIO_WORKLET
1433-
// Pthreads need their clocks synchronized to the execution of the main
1434-
// thread, so, when using them, make sure to adjust all timings to the
1435-
// respective time origins.
1436-
_emscripten_get_now = () => performance.timeOrigin + {{{ getPerformanceNow() }}}();
1432+
// Pthreads need their clocks synchronized to the execution of the main
1433+
// thread, so, when using them, make sure to adjust all timings to the
1434+
// respective time origins.
1435+
emscripten_get_now: () => performance.timeOrigin + {{{ getPerformanceNow() }}}(),
14371436
#else
14381437
#if MIN_FIREFOX_VERSION <= 14 || MIN_CHROME_VERSION <= 23 || MIN_SAFARI_VERSION <= 80400 || AUDIO_WORKLET // https://caniuse.com/#feat=high-resolution-time
1438+
emscripten_get_now: `;
14391439
// AudioWorkletGlobalScope does not have performance.now()
14401440
// (https://github.com/WebAudio/web-audio-api/issues/2527), so if building
14411441
// with
@@ -1449,14 +1449,14 @@ addToLibrary({
14491449
} else {
14501450
_emscripten_get_now = Date.now;
14511451
}
1452+
`,
14521453
#else
1453-
// Modern environment where performance.now() is supported:
1454-
// N.B. a shorter form "_emscripten_get_now = performance.now;" is
1455-
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
1456-
_emscripten_get_now = () => {{{ getPerformanceNow() }}}();
1454+
// Modern environment where performance.now() is supported:
1455+
// N.B. a shorter form "_emscripten_get_now = performance.now;" is
1456+
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
1457+
emscripten_get_now: () => {{{ getPerformanceNow() }}}(),
14571458
#endif
14581459
#endif
1459-
`,
14601460

14611461
emscripten_get_now_res: () => { // return resolution of get_now, in nanoseconds
14621462
#if ENVIRONMENT_MAY_BE_NODE
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8354
1+
8347
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20427
1+
20408
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4916
1+
4913
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10465
1+
10458

0 commit comments

Comments
 (0)