Skip to content

Commit 92a971b

Browse files
VirtualTimkripken
authored andcommitted
Clean up worker.js a bit (#9018)
Removed unused functions/vars, terminated unterminated statements, * Changed const to var * Change "this.err" to "var err" * tempDoublePtr should only be available in !MODULARIZE
1 parent e0dd370 commit 92a971b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/worker.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
var threadInfoStruct = 0; // Info area for this thread in Emscripten HEAP (shared). If zero, this worker is not currently hosting an executing pthread.
1212
var selfThreadId = 0; // The ID of this thread. 0 if not hosting a pthread.
1313
var parentThreadId = 0; // The ID of the parent pthread that launched this thread.
14-
#if !WASM_BACKEND
14+
#if !WASM_BACKEND && !MODULARIZE
1515
var tempDoublePtr = 0; // A temporary memory area for global float and double marshalling operations.
1616
#endif
1717

@@ -59,10 +59,6 @@ this.addEventListener('error', function(e) {
5959
console.error(e.error);
6060
});
6161

62-
function threadPrint() {
63-
var text = Array.prototype.slice.call(arguments).join(' ');
64-
console.log(text);
65-
}
6662
function threadPrintErr() {
6763
var text = Array.prototype.slice.call(arguments).join(' ');
6864
console.error(text);
@@ -72,20 +68,19 @@ function threadAlert() {
7268
var text = Array.prototype.slice.call(arguments).join(' ');
7369
postMessage({cmd: 'alert', text: text, threadId: selfThreadId});
7470
}
75-
out = threadPrint;
76-
err = threadPrintErr;
71+
var err = threadPrintErr;
7772
this.alert = threadAlert;
7873

7974
#if WASM
8075
Module['instantiateWasm'] = function(info, receiveInstance) {
8176
// Instantiate from the module posted from the main thread.
8277
// We can just use sync instantiation in the worker.
83-
instance = new WebAssembly.Instance(wasmModule, info);
78+
var instance = new WebAssembly.Instance(wasmModule, info);
8479
// We don't need the module anymore; new threads will be spawned from the main thread.
8580
wasmModule = null;
8681
receiveInstance(instance); // The second 'module' parameter is intentionally null here, we don't need to keep a ref to the Module object from here.
8782
return instance.exports;
88-
}
83+
};
8984
#endif
9085

9186
var wasmModule;
@@ -275,4 +270,4 @@ this.onmessage = function(e) {
275270
console.error(e.stack);
276271
throw e;
277272
}
278-
}
273+
};

0 commit comments

Comments
 (0)