1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 16:17:59 +01:00

Minor performance work.

This commit is contained in:
Kris Maglione
2011-02-03 02:34:40 -05:00
parent edecec56f9
commit b10e4e4b3a
5 changed files with 21 additions and 10 deletions

View File

@@ -111,13 +111,13 @@ update(CommandOption, {
var Command = Class("Command", {
init: function (specs, description, action, extraInfo) {
specs = Array.concat(specs); // XXX
let parsedSpecs = Command.parseSpecs(specs);
let parsedSpecs = extraInfo.parsedSpecs || Command.parseSpecs(specs);
this.specs = specs;
this.shortNames = array.compact(parsedSpecs.map(function (n) n[1]));
this.longNames = parsedSpecs.map(function (n) n[0]);
this.name = this.longNames[0];
this.names = array(parsedSpecs).flatten();
this.names = array.flatten(parsedSpecs);
this.description = description;
this.action = action;
@@ -471,11 +471,15 @@ var Commands = Module("commands", {
args[3].definedAt = commands.getCaller(Components.stack.caller.caller);
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),
"E182: Can't replace non-user command: " + args[0][0]);
if (!replace || !args[3].user)
dactyl.assert(!names.some(function (name) name in this._exMap, this),
"Not replacing command " + args[0]);
for (let name in values(names)) {
ex.__defineGetter__(name, function () this._run(name));
if (name in this._exMap)
@@ -484,8 +488,10 @@ var Commands = Module("commands", {
let name = names[0];
let closure = function () commands._exMap[name];
memoize(this._exMap, name, function () Command.apply(null, args));
memoize(this._exCommands, this._exCommands.length, closure);
for (let alias in values(names.slice(1)))
memoize(this._exMap, alias, closure);

View File

@@ -36,8 +36,7 @@ var Map = Class("Map", {
this.id = ++Map.id;
this.modes = modes;
this.names = keys.map(events.closure.canonicalKeys);
this.name = this.names[0];
this._keys = keys;
this.action = action;
this.description = description;
@@ -48,14 +47,17 @@ var Map = Class("Map", {
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)],
/** @property {number} A unique ID for this mapping. */
id: null,
/** @property {number[]} All of the modes for which this mapping applies. */
modes: null,
/** @property {string[]} All of this mapping's names (key sequences). */
names: null,
/** @property {function (number)} The function called to execute this mapping. */
action: null,
/** @property {string} This mapping's description, as shown in :listkeys. */

View File

@@ -22,6 +22,7 @@ var StatusLine = Module("statusline", {
#addon-bar > #addonbar-closebutton { visibility: collapse; }
#addon-bar > xul|toolbarspring { visibility: collapse; }
]]></css>);
highlight.loadCSS(util.compileMacro(<![CDATA[
!AddonBar;#addon-bar {
padding-left: 0 !important;

View File

@@ -984,9 +984,11 @@ var Completion = Module("completion", {
modules.CompletionContext = Class("CompletionContext", CompletionContext, {
init: function init() {
this.options = modules.options;
this.modules = modules;
return init.superapply(this, arguments);
}
},
get options() this.modules.options
});
},
commands: function (dactyl, modules, window) {

View File

@@ -159,7 +159,7 @@ var Overlay = Module("Overlay", {
"services",
"storage",
"util"
].forEach(function (name) require(jsmodules, name));
].forEach(function (name) defineModule.time("load", name, require, null, jsmodules, name));
["dactyl",
"modes",
@@ -181,7 +181,7 @@ var Overlay = Module("Overlay", {
"statusline",
"styles",
"template"
].forEach(modules.load);
].forEach(function (name) defineModule.time("load", name, modules.load, modules, name));
config.scripts.forEach(modules.load);
}, this);