From d65edaa232c92677033b077ddbe87b722b689833 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 3 Nov 2022 17:34:59 +1100 Subject: [PATCH] webassembly: Use Date's now() instead of getTime(). Using now() is a bit faster because it doesn't need to create a new Date. Signed-off-by: Damien George --- ports/webassembly/library.js | 2 +- ports/webassembly/wrapper.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/webassembly/library.js b/ports/webassembly/library.js index a8e54aaaca..27078e504f 100644 --- a/ports/webassembly/library.js +++ b/ports/webassembly/library.js @@ -42,7 +42,7 @@ mergeInto(LibraryManager.library, { }, mp_js_ticks_ms: function() { - return (new Date()).getTime() - MP_JS_EPOCH; + return Date.now() - MP_JS_EPOCH; }, mp_js_hook: function() { diff --git a/ports/webassembly/wrapper.js b/ports/webassembly/wrapper.js index ae0f24e7e4..dcbfe6c017 100644 --- a/ports/webassembly/wrapper.js +++ b/ports/webassembly/wrapper.js @@ -33,7 +33,7 @@ var mainProgram = function() mp_js_init_repl = Module.cwrap('mp_js_init_repl', 'null', ['null']); mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number']); - MP_JS_EPOCH = (new Date()).getTime(); + MP_JS_EPOCH = Date.now(); if (typeof window === 'undefined' && require.main === module) { var fs = require('fs');