From a9bcc70a2b5aef140f75fec76e44a067195bbef0 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 23 Dec 2019 09:07:42 -0500 Subject: [PATCH] Minor code review of WASM-loading code --- src/js/hntrie.js | 7 +++---- src/js/start.js | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/hntrie.js b/src/js/hntrie.js index 4c2e662..3ab3117 100644 --- a/src/js/hntrie.js +++ b/src/js/hntrie.js @@ -519,12 +519,11 @@ const HNTrieContainer = class { } async initWASM() { + if ( this.wasmInstancePromise !== null ) { + return this.wasmInstancePromise; + } const module = await HNTrieContainer.enableWASM(); if ( module instanceof WebAssembly.Module === false ) { return false; } - - if ( this.wasmInstancePromise !== null ) { - return true; - } const memory = new WebAssembly.Memory({ initial: 2 }); this.wasmInstancePromise = WebAssembly.instantiate( module, diff --git a/src/js/start.js b/src/js/start.js index fa1d7a0..bd37cc9 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -32,7 +32,9 @@ ]); log.info(`User settings ready ${Date.now()-vAPI.T0} ms after launch`); - const shouldWASM = µm.rawSettings.disableWebAssembly !== true; + const shouldWASM = + vAPI.canWASM === true && + µm.rawSettings.disableWebAssembly !== true; if ( shouldWASM ) { await Promise.all([ µm.HNTrieContainer.enableWASM(),