From a22879631fbeab99ed385ea52ec34b47d4aea18d Mon Sep 17 00:00:00 2001 From: David Aylaian Date: Wed, 27 Dec 2017 19:44:49 -0500 Subject: [PATCH] Optimize stepThread by reducing the number of calls to peekStack --- src/engine/sequencer.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/sequencer.js b/src/engine/sequencer.js index 2db1c6ed8..2db6054b7 100644 --- a/src/engine/sequencer.js +++ b/src/engine/sequencer.js @@ -174,7 +174,8 @@ class Sequencer { // A "null block" - empty branch. thread.popStack(); } - while (thread.peekStack()) { + // Save the current block ID to notice if we did control flow. + while ((currentBlockId = thread.peekStack()) !== 0) { let isWarpMode = thread.peekStackFrame().warpMode; if (isWarpMode && !thread.warpTimer) { // Initialize warp-mode timer if it hasn't been already. @@ -183,8 +184,6 @@ class Sequencer { thread.warpTimer.start(); } // Execute the current block. - // Save the current block ID to notice if we did control flow. - currentBlockId = thread.peekStack(); if (this.runtime.profiler !== null) { if (executeProfilerId === -1) { executeProfilerId = this.runtime.profiler.idByName(executeProfilerFrame);