1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 09:48:00 +01:00

Normalise use of "res" vs "ret" for return variables.

This commit is contained in:
Doug Kearns
2011-03-07 21:41:07 +11:00
parent 7bf3f40ab0
commit 1c4c5e5ad3
6 changed files with 46 additions and 47 deletions

View File

@@ -230,9 +230,9 @@ Runnable.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIRunnable]);
*/ */
function debuggerProperties(obj) { function debuggerProperties(obj) {
if (loaded.services && services.debugger.isOn) { if (loaded.services && services.debugger.isOn) {
let ret = {}; let res = {};
services.debugger.wrapValue(obj).getProperties(ret, {}); services.debugger.wrapValue(obj).getProperties(res, {});
return ret.value; return res.value;
} }
} }
@@ -1487,20 +1487,20 @@ var array = Class("array", Array, {
* @returns {Array} * @returns {Array}
*/ */
uniq: function uniq(ary, unsorted) { uniq: function uniq(ary, unsorted) {
let ret = []; let res = [];
if (unsorted) { if (unsorted) {
for (let item in values(ary)) for (let item in values(ary))
if (ret.indexOf(item) == -1) if (res.indexOf(item) == -1)
ret.push(item); res.push(item);
} }
else { else {
for (let [, item] in Iterator(ary.sort())) { for (let [, item] in Iterator(ary.sort())) {
if (item != last || !ret.length) if (item != last || !res.length)
ret.push(item); res.push(item);
var last = item; var last = item;
} }
} }
return ret; return res;
}, },
/** /**

View File

@@ -180,8 +180,7 @@ var JavaScript = Module("javascript", {
this._top.statements.pop(); this._top.statements.pop();
this._top = this._get(-2); this._top = this._get(-2);
this._last = this._top.char; this._last = this._top.char;
let ret = this._stack.pop(); return this._stack.pop();
return ret;
}, },
_buildStack: function (filter) { _buildStack: function (filter) {

View File

@@ -872,54 +872,54 @@ var Options = Module("options", {
* @returns {Object} The parsed command object. * @returns {Object} The parsed command object.
*/ */
parseOpt: function parseOpt(args, modifiers) { parseOpt: function parseOpt(args, modifiers) {
let ret = {}; let res = {};
let matches, prefix, postfix; let matches, prefix, postfix;
[matches, prefix, ret.name, postfix, ret.valueGiven, ret.operator, ret.value] = [matches, prefix, res.name, postfix, res.valueGiven, res.operator, res.value] =
args.match(/^\s*(no|inv)?([^=]+?)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || []; args.match(/^\s*(no|inv)?([^=]+?)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || [];
ret.args = args; res.args = args;
ret.onlyNonDefault = false; // used for :set to print non-default options res.onlyNonDefault = false; // used for :set to print non-default options
if (!args) { if (!args) {
ret.name = "all"; res.name = "all";
ret.onlyNonDefault = true; res.onlyNonDefault = true;
} }
if (matches) { if (matches) {
ret.option = this.get(ret.name, ret.scope); res.option = this.get(res.name, res.scope);
if (!ret.option && (ret.option = this.get(prefix + ret.name, ret.scope))) { if (!res.option && (res.option = this.get(prefix + res.name, res.scope))) {
ret.name = prefix + ret.name; res.name = prefix + res.name;
prefix = ""; prefix = "";
} }
} }
ret.prefix = prefix; res.prefix = prefix;
ret.postfix = postfix; res.postfix = postfix;
ret.all = (ret.name == "all"); res.all = (res.name == "all");
ret.get = (ret.all || postfix == "?" || (ret.option && ret.option.type != "boolean" && !ret.valueGiven)); res.get = (res.all || postfix == "?" || (res.option && res.option.type != "boolean" && !res.valueGiven));
ret.invert = (prefix == "inv" || postfix == "!"); res.invert = (prefix == "inv" || postfix == "!");
ret.reset = (postfix == "&"); res.reset = (postfix == "&");
ret.unsetBoolean = (prefix == "no"); res.unsetBoolean = (prefix == "no");
ret.scope = modifiers && modifiers.scope; res.scope = modifiers && modifiers.scope;
if (!ret.option) if (!res.option)
return ret; return res;
if (ret.value === undefined) if (res.value === undefined)
ret.value = ""; res.value = "";
ret.optionValue = ret.option.get(ret.scope); res.optionValue = res.option.get(res.scope);
try { try {
ret.values = ret.option.parse(ret.value); res.values = res.option.parse(res.value);
} }
catch (e) { catch (e) {
ret.error = e; res.error = e;
} }
return ret; return res;
}, },
/** /**

View File

@@ -83,20 +83,20 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
}, },
pop: function pop(value) { pop: function pop(value) {
var ret = this._object.pop(); var res = this._object.pop();
this.fireEvent("pop", this._object.length); this.fireEvent("pop", this._object.length);
return ret; return res;
}, },
truncate: function truncate(length, fromEnd) { truncate: function truncate(length, fromEnd) {
var ret = this._object.length; var res = this._object.length;
if (this._object.length > length) { if (this._object.length > length) {
if (fromEnd) if (fromEnd)
this._object.splice(0, this._object.length - length); this._object.splice(0, this._object.length - length);
this._object.length = length; this._object.length = length;
this.fireEvent("truncate", length); this.fireEvent("truncate", length);
} }
return ret; return res;
}, },
// XXX: Awkward. // XXX: Awkward.

View File

@@ -90,19 +90,19 @@ var Template = Module("Template", {
XML.ignoreWhitespace = false; XML.prettyPrinting = false; XML.ignoreWhitespace = false; XML.prettyPrinting = false;
if (iter.length) // FIXME: Kludge? if (iter.length) // FIXME: Kludge?
iter = array.iterValues(iter); iter = array.iterValues(iter);
let ret = <></>; let res = <></>;
let n = 0; let n = 0;
for each (let i in Iterator(iter)) { for each (let i in Iterator(iter)) {
let val = func(i, n); let val = func(i, n);
if (val == undefined) if (val == undefined)
continue; continue;
if (n++ && sep) if (n++ && sep)
ret += sep; res += sep;
if (interruptable && n % interruptable == 0) if (interruptable && n % interruptable == 0)
util.threadYield(true, true); util.threadYield(true, true);
ret += val; res += val;
} }
return ret; return res;
}, },
bindings: { bindings: {

View File

@@ -132,15 +132,15 @@ const Mail = Module("mail", {
/** @property {nsISmtpServer[]} The list of configured SMTP servers. */ /** @property {nsISmtpServer[]} The list of configured SMTP servers. */
get smtpServers() { get smtpServers() {
let servers = services.smtp.smtpServers; let servers = services.smtp.smtpServers;
let ret = []; let res = [];
while (servers.hasMoreElements()) { while (servers.hasMoreElements()) {
let server = servers.getNext(); let server = servers.getNext();
if (server instanceof Ci.nsISmtpServer) if (server instanceof Ci.nsISmtpServer)
ret.push(server); res.push(server);
} }
return ret; return res;
}, },
composeNewMail: function (args) { composeNewMail: function (args) {