You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// "The opcode is a two-digit number based only on the ones and tens digit of the value, that is, the opcode is the rightmost two digits of the first value in an instruction"
@@ -194,8 +211,6 @@ class Computer {
194
211
op.modes[Math.abs(i-op.params+1)]=full_op[i];
195
212
}
196
213
197
-
letend=newDate();
198
-
this.parseOpTime+=(end-start);
199
214
returnop;
200
215
}
201
216
@@ -299,7 +314,33 @@ class Computer {
299
314
}
300
315
301
316
// If result is `true`, we moved the pointer
302
-
letresult=fn(...values);
317
+
letresult;
318
+
319
+
/**
320
+
* Always spreading args is slow, so we can create a few base cases
321
+
* (actually all our base cases) to speed up these function calls.
322
+
* We still have a default case if for some reason we have an op
323
+
* with more than 3 params (we don't), so this code is future proof,
324
+
* but this change offers a ~2x speed improvement.
325
+
*/
326
+
switch(params){
327
+
case0:
328
+
result=fn();
329
+
break;
330
+
case1:
331
+
result=fn(values[0]);
332
+
break;
333
+
case2:
334
+
result=fn(values[0],values[1]);
335
+
break;
336
+
case3:
337
+
result=fn(values[0],values[1],values[2]);
338
+
break;
339
+
default:
340
+
// Spreads are slow, so use direct branches for known number of params
0 commit comments