Use iteration instead of recursion when processing single frame

This commit is contained in:
Marcin Kulik 2011-03-09 20:19:09 +01:00
parent 4c6a5bd129
commit 12cdd612d7
3 changed files with 26 additions and 26 deletions

View File

@ -13,7 +13,7 @@
<div id="all">
<div id="top">
<div id="logo">
<h1>vterm.tv</h1>
<h1>t3rm.tv</h1>
</div>
<div id="menu">
<ul class="links">

View File

@ -142,13 +142,12 @@ SP.AnsiInterpreter.prototype = {
},
feed: function(data) {
if (data.length == 0) return;
// console.log(data);
var match;
var handler;
while (data.length > 0) {
match = handler = null;
for (var i=0; i<this.COMPILED_PATTERNS.length; i++) {
var pattern = this.COMPILED_PATTERNS[i];
match = pattern[0].exec(data);
@ -161,7 +160,7 @@ SP.AnsiInterpreter.prototype = {
if (handler) {
handler.call(this, data, match);
this.feed(data.slice(match[0].length));
data = data.slice(match[0].length)
} else {
@ -174,6 +173,7 @@ SP.AnsiInterpreter.prototype = {
throw 'bummer';
return;
}
}
}

View File

@ -25,7 +25,7 @@ SP.Player.prototype = {
this.terminal.restartCursorBlink();
// setTimeout(function() {
setTimeout(function() {
// console.log(this.dataIndex);
// console.log(this.currentData);
this.interpreter.feed(this.currentData);
@ -39,7 +39,7 @@ SP.Player.prototype = {
if (!window.stopped) {
this.nextFrame();
}
// }.bind(this), timing[0] * 1000 * (1.0 / speed));
}.bind(this), timing[0] * 1000 * (1.0 / speed));
}
}