Skip to content

Commit b57d103

Browse files
committed
Code size
1 parent f427472 commit b57d103

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

test/code_size/audio_worklet_wasm.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
var l = globalThis.Module || "undefined" != typeof Module ? Module : {}, n = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, t, v, I, J, F, C, z, X, E, B, A, Y, Z;
1+
var l = globalThis.Module || "undefined" != typeof Module ? Module : {}, n = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, r, v, I, J, F, C, z, X, E, B, A, Y, Z;
22

33
q && (n = !0);
44

55
function u(a) {
6-
t = a;
7-
v = a.L;
6+
r = a;
7+
v = a.M;
88
w();
99
l ||= {};
10-
l.wasm = a.H;
10+
l.wasm = a.I;
1111
y();
12-
a.H = a.M = 0;
12+
a.I = a.N = 0;
1313
}
1414

1515
n && !q && (onmessage = a => {
@@ -27,18 +27,22 @@ if (q) {
2727
this.A = d.A;
2828
this.u = d.u;
2929
this.s = 4 * this.u;
30-
this.F = Math.min((t.D - 16) / this.s | 0, 64);
31-
d = A();
32-
var f = B(this.F * this.s) >> 2;
33-
this.G = [];
34-
for (var g = this.F; 0 < g; g--) this.G.unshift(C.subarray(f, f += this.u));
30+
this.C = Math.min((r.G - 16) / this.s | 0, 64);
31+
this.B = [];
32+
this.H();
33+
}
34+
H() {
35+
var d = A(), f = B(this.C * this.s) >> 2;
36+
this.B.length = 0;
37+
for (var g = this.C; 0 < g; g--) this.B.unshift(C.subarray(f, f += this.u));
3538
E(d);
3639
}
3740
static get parameterDescriptors() {
3841
return c;
3942
}
4043
process(d, f, g) {
41-
var p = d.length, x = f.length, k, r, h = 12 * (p + x), m = 0;
44+
C.buffer != this.B[0].buffer && this.H();
45+
var p = d.length, x = f.length, k, t, h = 12 * (p + x), m = 0;
4246
for (k of d) m += k.length * this.s;
4347
var G = 0;
4448
for (k of f) G += k.length;
@@ -54,15 +58,15 @@ if (q) {
5458
F[h + 4 >> 2] = this.u;
5559
F[h + 8 >> 2] = m;
5660
h += 12;
57-
for (r of k) C.set(r, m >> 2), m += this.s;
61+
for (t of k) C.set(t, m >> 2), m += this.s;
5862
}
5963
d = h;
60-
for (k = 0; r = g[k++]; ) F[h >> 2] = r.length, F[h + 4 >> 2] = m, h += 8, C.set(r, m >> 2),
61-
m += 4 * r.length;
64+
for (k = 0; t = g[k++]; ) F[h >> 2] = t.length, F[h + 4 >> 2] = m, h += 8, C.set(t, m >> 2),
65+
m += 4 * t.length;
6266
g = h;
6367
for (k of f) F[h >> 2] = k.length, F[h + 4 >> 2] = this.u, F[h + 8 >> 2] = m, h += 12,
6468
m += this.s * k.length;
65-
if (p = this.v(p, D, x, g, N, d, this.A)) for (k of f) for (r of k) r.set(this.G[--G]);
69+
if (p = this.v(p, D, x, g, N, d, this.A)) for (k of f) for (t of k) t.set(this.B[--G]);
6670
E(U);
6771
return !!p;
6872
}
@@ -77,10 +81,10 @@ if (q) {
7781
H = this.port;
7882
H.onmessage = async e => {
7983
e = e.data;
80-
e._wpn ? (registerProcessor(e._wpn, a(e.I)), H.postMessage({
84+
e._wpn ? (registerProcessor(e._wpn, a(e.J)), H.postMessage({
8185
_wsc: e.v,
82-
B: [ e.J, 1, e.A ]
83-
})) : e._wsc && z.get(e._wsc)(...e.B);
86+
D: [ e.K, 1, e.A ]
87+
})) : e._wsc && z.get(e._wsc)(...e.D);
8488
};
8589
}
8690
process() {}
@@ -172,33 +176,33 @@ var K = [], L = a => {
172176
maxValue: C[b + 8 >> 2],
173177
automationRate: (J[b + 12 >> 2] ? "k" : "a") + "-rate"
174178
}), b += 16;
175-
Q[a].audioWorklet.C.port.postMessage({
179+
Q[a].audioWorklet.F.port.postMessage({
176180
_wpn: f,
177-
I: d,
178-
J: a,
181+
J: d,
182+
K: a,
179183
v: c,
180184
A: e
181185
});
182186
}, ca = () => !1, da = 1, ea = a => {
183187
a = a.data;
184188
var b = a._wsc;
185-
b && z.get(b)(...a.B);
189+
b && z.get(b)(...a.D);
186190
}, fa = a => B(a), ha = (a, b, c, e, d) => {
187191
var f = Q[a], g = f.audioWorklet, p = () => {
188192
z.get(e)(a, 0, d);
189193
};
190194
if (!g) return p();
191195
g.addModule(l.js).then((() => {
192-
g.C = new AudioWorkletNode(f, "em-bootstrap", {
196+
g.F = new AudioWorkletNode(f, "em-bootstrap", {
193197
processorOptions: {
194-
N: da++,
195-
H: l.wasm,
196-
L: v,
197-
K: b,
198-
D: c
198+
O: da++,
199+
I: l.wasm,
200+
M: v,
201+
L: b,
202+
G: c
199203
}
200204
});
201-
g.C.port.onmessage = ea;
205+
g.F.port.onmessage = ea;
202206
z.get(e)(a, 1, d);
203207
})).catch(p);
204208
};
@@ -238,7 +242,7 @@ function y() {
238242
l.stackAlloc = fa;
239243
l.stackRestore = O;
240244
l.wasmTable = z;
241-
n ? (Y(t.K, t.D), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", M),
245+
n ? (Y(r.L, r.G), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", M),
242246
K = K.forEach(L), addEventListener("message", L))) : a.i();
243247
n || X();
244248
}));
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 519,
33
"a.html.gz": 357,
4-
"a.js": 4041,
5-
"a.js.gz": 2115,
4+
"a.js": 4107,
5+
"a.js.gz": 2137,
66
"a.wasm": 1288,
77
"a.wasm.gz": 860,
8-
"total": 5848,
9-
"total_gz": 3332
8+
"total": 5914,
9+
"total_gz": 3354
1010
}

0 commit comments

Comments
 (0)