From 667883b3d5161e86f92e25619c585292d4bd2526 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Mon, 8 Apr 2024 13:53:16 +0200 Subject: [PATCH] fix js_wasm `time.tick_now`, `performance.now()` returns a float --- core/time/time_js.odin | 4 ++-- vendor/wasm/js/runtime.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/time/time_js.odin b/core/time/time_js.odin index 932fc2b8e..c5090df90 100644 --- a/core/time/time_js.odin +++ b/core/time/time_js.odin @@ -24,9 +24,9 @@ _sleep :: proc "contextless" (d: Duration) { _tick_now :: proc "contextless" () -> Tick { foreign odin_env { - tick_now :: proc "contextless" () -> i64 --- + tick_now :: proc "contextless" () -> f32 --- } - return Tick{tick_now()*1e6} + return Tick{i64(tick_now()*1e6)} } _yield :: proc "contextless" () { diff --git a/vendor/wasm/js/runtime.js b/vendor/wasm/js/runtime.js index f5ca325f8..85be84caf 100644 --- a/vendor/wasm/js/runtime.js +++ b/vendor/wasm/js/runtime.js @@ -1335,7 +1335,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) { // return a bigint to be converted to i64 time_now: () => BigInt(Date.now()), - tick_now: () => BigInt(performance.now()), + tick_now: () => performance.now(), time_sleep: (duration_ms) => { if (duration_ms > 0) { // TODO(bill): Does this even make any sense?