mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-05-19 03:33:17 +12:00
Minor code review of WASM-loading code
This commit is contained in:
parent
2936d73911
commit
a9bcc70a2b
|
@ -519,12 +519,11 @@ const HNTrieContainer = class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async initWASM() {
|
async initWASM() {
|
||||||
|
if ( this.wasmInstancePromise !== null ) {
|
||||||
|
return this.wasmInstancePromise;
|
||||||
|
}
|
||||||
const module = await HNTrieContainer.enableWASM();
|
const module = await HNTrieContainer.enableWASM();
|
||||||
if ( module instanceof WebAssembly.Module === false ) { return false; }
|
if ( module instanceof WebAssembly.Module === false ) { return false; }
|
||||||
|
|
||||||
if ( this.wasmInstancePromise !== null ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const memory = new WebAssembly.Memory({ initial: 2 });
|
const memory = new WebAssembly.Memory({ initial: 2 });
|
||||||
this.wasmInstancePromise = WebAssembly.instantiate(
|
this.wasmInstancePromise = WebAssembly.instantiate(
|
||||||
module,
|
module,
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
]);
|
]);
|
||||||
log.info(`User settings ready ${Date.now()-vAPI.T0} ms after launch`);
|
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 ) {
|
if ( shouldWASM ) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
µm.HNTrieContainer.enableWASM(),
|
µm.HNTrieContainer.enableWASM(),
|
||||||
|
|
Loading…
Reference in a new issue