Skip to content

Commit

Permalink
microoptimization was a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
canonic-epicure committed Jun 18, 2020
1 parent 2421d6b commit 54146af
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/chrono2/Quark.ts
Expand Up @@ -204,11 +204,8 @@ export class Atom extends Owner implements Identifiable, Uniqable {

const toVisit : Quark[] = [ this.immutable ]

// avoiding `push/pop` is noticeably faster
let length : number = 1

while (length) {
const quark = toVisit[ --length ]
while (toVisit.length) {
const quark = toVisit.pop()

const atom = quark.owner

Expand All @@ -219,7 +216,7 @@ export class Atom extends Owner implements Identifiable, Uniqable {
}

quark.forEachOutgoing(outgoing => {
if (outgoing.owner.state === AtomState.UpToDate) toVisit[ length++ ] = outgoing
if (outgoing.owner.state === AtomState.UpToDate) toVisit.push(outgoing)
})
}

Expand Down

0 comments on commit 54146af

Please sign in to comment.