Bombe: Firefox optimisation

Switch a couple of for of loops in the critical path for classic fors.
This loses about 10% performance in Chrome, but it brings Firefox
performance in line with Chrome's, rather than 2.5 times slower.
This commit is contained in:
s2224834 2019-01-10 18:44:50 +00:00
parent 3eb44708e5
commit 78768e00d4
1 changed files with 4 additions and 2 deletions

View File

@ -514,7 +514,8 @@ export class BombeMachine {
const idxPair = 26*j + i;
this.wires[idxPair] = true;
for (const scrambler of this.scramblers[i]) {
for (let k=0; k<this.scramblers[i].length; k++) {
const scrambler = this.scramblers[i][k];
const out = scrambler.transform(j);
const other = scrambler.getOtherEnd(i);
this.energise(other, out);
@ -522,7 +523,8 @@ export class BombeMachine {
if (i === j) {
return;
}
for (const scrambler of this.scramblers[j]) {
for (let k=0; k<this.scramblers[j].length; k++) {
const scrambler = this.scramblers[j][k];
const out = scrambler.transform(i);
const other = scrambler.getOtherEnd(j);
this.energise(other, out);