Skip to content

Commit

Permalink
Minor code review of WASM-loading code
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Dec 23, 2019
1 parent 2936d73 commit a9bcc70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/js/hntrie.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,11 @@ const HNTrieContainer = class {
}

async initWASM() {
const module = await HNTrieContainer.enableWASM();
if ( module instanceof WebAssembly.Module === false ) { return false; }

if ( this.wasmInstancePromise !== null ) {
return true;
return this.wasmInstancePromise;
}
const module = await HNTrieContainer.enableWASM();
if ( module instanceof WebAssembly.Module === false ) { return false; }
const memory = new WebAssembly.Memory({ initial: 2 });
this.wasmInstancePromise = WebAssembly.instantiate(
module,
Expand Down
4 changes: 3 additions & 1 deletion src/js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit a9bcc70

Please sign in to comment.