From c9c9cea6d032113d17723b01a0e6a078ac63a39c Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 29 Jan 2016 23:26:05 +1100 Subject: [PATCH] Remove remaining comprehensions. --- common/content/hints.js | 7 ++++--- common/modules/contexts.jsm | 12 ++++++++---- common/modules/highlight.jsm | 18 ++++++++++-------- common/modules/options.jsm | 6 +++++- common/modules/overlay.jsm | 8 +++++--- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/common/content/hints.js b/common/content/hints.js index d2307657..a0df5846 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -290,9 +290,10 @@ var HintSession = Class("HintSession", CommandMode, { let doc = win.document; memoize(doc, "dactylLabels", () => - iter([l.getAttribute("for"), l] - for (l of doc.querySelectorAll("label[for]"))) - .toObject()); + iter(function* () { + for (let l of doc.querySelectorAll("label[for]")) + yield [l.getAttribute("for"), l]; + }()).toObject()); let [offsetX, offsetY] = this.getContainerOffsets(doc); diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index 09dee79c..2a10a481 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -542,14 +542,18 @@ var Contexts = Module("contexts", { var makeParams = function makeParams(self, args) { let obj = params.apply(self, args); - return iter.toObject([k, Proxy(obj, k)] - for (k of properties(obj))); + return iter.toObject(function* () { + for (let k of properties(obj)) + yield [k, Proxy(obj, k)]; + }()); }; else if (params) makeParams = function makeParams(self, args) { - return iter.toObject([name, process(args[i])] - for ([i, name] of iter(params))); + return iter.toObject(function* () { + for (let [i, name] of iter(params)) + yield [name, process(args[i])]; + }()); }; let rhs = args.literalArg; diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index f071445b..882dac4c 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -378,14 +378,16 @@ var Highlights = Module("Highlight", { template.tabular(["Key", "Sample", "Link", "CSS"], ["padding: 0 1em 0 0; vertical-align: top; max-width: 16em; overflow: hidden;", "text-align: center"], - ([h.class, - ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"], - template.map(h.extends, s => template.highlight(s), ","), - template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g, - match => ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match]) - ] - for (h of highlight) - if (!key || h.class.indexOf(key) > -1)))); + (function* () { + for (let h of highlight) + if (!key || h.class.indexOf(key) > -1) + yield [h.class, + ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"], + template.map(h.extends, s => template.highlight(s), ","), + template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g, + match => ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])]; + }()) + )); else if (!key && clear) highlight.clear(); else if (key) diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 3ad98efc..013e5278 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -548,7 +548,11 @@ var Option = Class("Option", { }, stringmap: function (vals) { - return [Option.quote(k, /:/) + ":" + Option.quote(v, /:/) for ([k, v] of iter(vals))].join(","); + return Array.from(iter(vals), + ([k, v]) => Option.quote(k, /:/) + + ":" + + Option.quote(v, /:/)) + .join(","); }, regexplist: vals => vals.join(","), diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index 0f82ed54..bfa3509f 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -304,9 +304,11 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen // Urgh. Hack. let namespaces; if (attrs) - namespaces = iter([k.slice(6), DOM.fromJSON.namespaces[v] || v] - for ([k, v] of iter(attrs)) - if (/^xmlns(?:$|:)/.test(k))).toObject(); + namespaces = iter(function* () { + for (let [k, v] of iter(attrs)) + if (/^xmlns(?:$|:)/.test(k)) + yield [k.slice(6), DOM.fromJSON.namespaces[v] || v]; + }()).toObject(); let node = DOM.fromJSON(xml, doc, obj.objects, namespaces);