1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-05-05 21:03:17 +12:00

Minor code review of WASM-loading code

This commit is contained in:
Raymond Hill 2019-12-23 09:07:42 -05:00
parent 2936d73911
commit a9bcc70a2b
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 6 additions and 5 deletions

View file

@ -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,

View file

@ -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(),