mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 21:28:00 +01:00
Minor performance work.
This commit is contained in:
@@ -111,13 +111,13 @@ update(CommandOption, {
|
|||||||
var Command = Class("Command", {
|
var Command = Class("Command", {
|
||||||
init: function (specs, description, action, extraInfo) {
|
init: function (specs, description, action, extraInfo) {
|
||||||
specs = Array.concat(specs); // XXX
|
specs = Array.concat(specs); // XXX
|
||||||
let parsedSpecs = Command.parseSpecs(specs);
|
let parsedSpecs = extraInfo.parsedSpecs || Command.parseSpecs(specs);
|
||||||
|
|
||||||
this.specs = specs;
|
this.specs = specs;
|
||||||
this.shortNames = array.compact(parsedSpecs.map(function (n) n[1]));
|
this.shortNames = array.compact(parsedSpecs.map(function (n) n[1]));
|
||||||
this.longNames = parsedSpecs.map(function (n) n[0]);
|
this.longNames = parsedSpecs.map(function (n) n[0]);
|
||||||
this.name = this.longNames[0];
|
this.name = this.longNames[0];
|
||||||
this.names = array(parsedSpecs).flatten();
|
this.names = array.flatten(parsedSpecs);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
|
||||||
@@ -471,11 +471,15 @@ var Commands = Module("commands", {
|
|||||||
args[3].definedAt = commands.getCaller(Components.stack.caller.caller);
|
args[3].definedAt = commands.getCaller(Components.stack.caller.caller);
|
||||||
|
|
||||||
let names = array.flatten(Command.parseSpecs(args[0]));
|
let names = array.flatten(Command.parseSpecs(args[0]));
|
||||||
|
args.parsedSpecs = names;
|
||||||
|
|
||||||
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this),
|
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this),
|
||||||
"E182: Can't replace non-user command: " + args[0][0]);
|
"E182: Can't replace non-user command: " + args[0][0]);
|
||||||
|
|
||||||
if (!replace || !args[3].user)
|
if (!replace || !args[3].user)
|
||||||
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
||||||
"Not replacing command " + args[0]);
|
"Not replacing command " + args[0]);
|
||||||
|
|
||||||
for (let name in values(names)) {
|
for (let name in values(names)) {
|
||||||
ex.__defineGetter__(name, function () this._run(name));
|
ex.__defineGetter__(name, function () this._run(name));
|
||||||
if (name in this._exMap)
|
if (name in this._exMap)
|
||||||
@@ -484,8 +488,10 @@ var Commands = Module("commands", {
|
|||||||
|
|
||||||
let name = names[0];
|
let name = names[0];
|
||||||
let closure = function () commands._exMap[name];
|
let closure = function () commands._exMap[name];
|
||||||
|
|
||||||
memoize(this._exMap, name, function () Command.apply(null, args));
|
memoize(this._exMap, name, function () Command.apply(null, args));
|
||||||
memoize(this._exCommands, this._exCommands.length, closure);
|
memoize(this._exCommands, this._exCommands.length, closure);
|
||||||
|
|
||||||
for (let alias in values(names.slice(1)))
|
for (let alias in values(names.slice(1)))
|
||||||
memoize(this._exMap, alias, closure);
|
memoize(this._exMap, alias, closure);
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ var Map = Class("Map", {
|
|||||||
|
|
||||||
this.id = ++Map.id;
|
this.id = ++Map.id;
|
||||||
this.modes = modes;
|
this.modes = modes;
|
||||||
this.names = keys.map(events.closure.canonicalKeys);
|
this._keys = keys;
|
||||||
this.name = this.names[0];
|
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
||||||
@@ -48,14 +47,17 @@ var Map = Class("Map", {
|
|||||||
update(this, extraInfo);
|
update(this, extraInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
name: Class.memoize(function () this.names[0]),
|
||||||
|
|
||||||
|
/** @property {string[]} All of this mapping's names (key sequences). */
|
||||||
|
names: Class.memoize(function () this._keys.map(events.closure.canonicalKeys)),
|
||||||
|
|
||||||
get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
|
get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
|
||||||
|
|
||||||
/** @property {number} A unique ID for this mapping. */
|
/** @property {number} A unique ID for this mapping. */
|
||||||
id: null,
|
id: null,
|
||||||
/** @property {number[]} All of the modes for which this mapping applies. */
|
/** @property {number[]} All of the modes for which this mapping applies. */
|
||||||
modes: null,
|
modes: null,
|
||||||
/** @property {string[]} All of this mapping's names (key sequences). */
|
|
||||||
names: null,
|
|
||||||
/** @property {function (number)} The function called to execute this mapping. */
|
/** @property {function (number)} The function called to execute this mapping. */
|
||||||
action: null,
|
action: null,
|
||||||
/** @property {string} This mapping's description, as shown in :listkeys. */
|
/** @property {string} This mapping's description, as shown in :listkeys. */
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ var StatusLine = Module("statusline", {
|
|||||||
#addon-bar > #addonbar-closebutton { visibility: collapse; }
|
#addon-bar > #addonbar-closebutton { visibility: collapse; }
|
||||||
#addon-bar > xul|toolbarspring { visibility: collapse; }
|
#addon-bar > xul|toolbarspring { visibility: collapse; }
|
||||||
]]></css>);
|
]]></css>);
|
||||||
|
|
||||||
highlight.loadCSS(util.compileMacro(<![CDATA[
|
highlight.loadCSS(util.compileMacro(<![CDATA[
|
||||||
!AddonBar;#addon-bar {
|
!AddonBar;#addon-bar {
|
||||||
padding-left: 0 !important;
|
padding-left: 0 !important;
|
||||||
|
|||||||
@@ -984,9 +984,11 @@ var Completion = Module("completion", {
|
|||||||
|
|
||||||
modules.CompletionContext = Class("CompletionContext", CompletionContext, {
|
modules.CompletionContext = Class("CompletionContext", CompletionContext, {
|
||||||
init: function init() {
|
init: function init() {
|
||||||
this.options = modules.options;
|
this.modules = modules;
|
||||||
return init.superapply(this, arguments);
|
return init.superapply(this, arguments);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
get options() this.modules.options
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
commands: function (dactyl, modules, window) {
|
commands: function (dactyl, modules, window) {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ var Overlay = Module("Overlay", {
|
|||||||
"services",
|
"services",
|
||||||
"storage",
|
"storage",
|
||||||
"util"
|
"util"
|
||||||
].forEach(function (name) require(jsmodules, name));
|
].forEach(function (name) defineModule.time("load", name, require, null, jsmodules, name));
|
||||||
|
|
||||||
["dactyl",
|
["dactyl",
|
||||||
"modes",
|
"modes",
|
||||||
@@ -181,7 +181,7 @@ var Overlay = Module("Overlay", {
|
|||||||
"statusline",
|
"statusline",
|
||||||
"styles",
|
"styles",
|
||||||
"template"
|
"template"
|
||||||
].forEach(modules.load);
|
].forEach(function (name) defineModule.time("load", name, modules.load, modules, name));
|
||||||
|
|
||||||
config.scripts.forEach(modules.load);
|
config.scripts.forEach(modules.load);
|
||||||
}, this);
|
}, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user