From 5a670ebd7b0a3500667a91866f7862033b4c4540 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 11 Oct 2010 01:49:58 -0400 Subject: [PATCH] Stem my patholigical tendency to use iterators wherever possible (but not my pathological desire to clean up perfectly servicable code). --- common/content/io.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/common/content/io.js b/common/content/io.js index 28c57fef..5a274dc6 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -362,32 +362,24 @@ lookup: this.readHeredoc = function (end) { let res = []; - try { - io.sourcing.line++; - while (true) - let ([i, line] = iter.next()) { - if (line === end) - return res.join("\n"); - res.push(line); - } + io.sourcing.line++; + while (++i < lines.length) { + if (lines[i] === end) + return res.join("\n"); + res.push(lines[i]); } - catch (e if e instanceof StopIteration) {} dactyl.assert(false, "Unexpected end of file waiting for " + end); }; - let iter = Iterator(lines); - for (let [i, line] in iter) { - if (this.sourcing.finished) - break; + for (var i = 0; i < lines.length && !this.sourcing.finished; i++) { + // Deal with editors from Silly OSs. + let line = lines[i].replace(/\r$/, ""); this.sourcing.line = i + 1; - // Deal with editors from Silly OSs. - line = line.replace(/\r$/, ""); - // Process escaped new lines - for (; i < lines.length && /^\s*\\/.test(lines[i + 1]); i++) - line += "\n" + iter.next()[1].replace(/^\s*\\/, ""); + while (i < lines.length && /^\s*\\/.test(lines[i + 1])) + line += "\n" + lines[++i].replace(/^\s*\\/, ""); try { dactyl.execute(line, { setFrom: file });