1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-24 06:05:45 +01:00

Fix some startup bottlenecks.

This commit is contained in:
Kris Maglione
2015-12-21 00:52:38 -08:00
parent 5a42ae42d6
commit 7aabc153f5
8 changed files with 136 additions and 69 deletions

View File

@@ -60,6 +60,33 @@ var ConfigBase = Class("ConfigBase", {
"resource://dactyl-content/")));
});
if (this.VCSPath) {
this.branch = new Promise(resolve => {
this.timeout(() => {
io.system(["hg", "-R", this.VCSPath, "branch"], "", true)
.then(result => {
resolve(result.output);
});
}, 1000);
});
this._version = new Promise(resolve => {
this.timeout(() => {
io.system(["hg", "-R", this.VCSPath, "log", "-r.",
"--template=hg{rev}-{branch}"], "", true)
.then(result => {
this.version = result.output;
resolve(this.version);
});
}, 1000);
});
}
else {
this.branch = Promise.resolve((/pre-hg\d+-(\S*)/.exec(this.version) || [])[1]);
this._version = null;
}
this.protocolLoaded = true;
this.timeout(function () {
cache.register("config.dtd", () => util.makeDTD(config.dtd),
@@ -208,8 +235,19 @@ var ConfigBase = Class("ConfigBase", {
get addonID() { return this.name + "@dactyl.googlecode.com"; },
addon: Class.Memoize(function () {
return (JSMLoader.bootstrap || {}).addon ||
AddonManager.getAddonByID(this.addonID);
return (JSMLoader.bootstrap || {}).addon;
}),
addonData: Class.Memoize(function () {
return (JSMLoader.bootstrap || {}).addonData;
}),
basePath: Class.Memoize(function () {
return (JSMLoader.bootstrap || {}).basePath;
}),
resourceURI: Class.Memoize(function () {
return this.addonData.resourceURI;
}),
get styleableChrome() { return Object.keys(this.overlays); },
@@ -379,8 +417,10 @@ var ConfigBase = Class("ConfigBase", {
* proxy file.
*/
VCSPath: Class.Memoize(function () {
if (/pre$/.test(this.addon.version)) {
let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
if (/pre$/.test(this.addonData.version)) {
// XXX: Sync.
let uri = util.newURI("../.hg", null, this.resourceURI);
if (uri instanceof Ci.nsIFileURL &&
uri.file.exists() &&
io.pathSearch("hg"))
@@ -389,17 +429,6 @@ var ConfigBase = Class("ConfigBase", {
return null;
}),
/**
* @property {string} The name of the VCS branch that the application is
* running from if using an extension proxy file or was built from if
* installed as an XPI.
*/
branch: Class.Memoize(function () {
if (this.VCSPath)
return io.system(["hg", "-R", this.VCSPath, "branch"]).output;
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
}),
/** @property {string} The name of the current user profile. */
profileName: Class.Memoize(function () {
// NOTE: services.profile.selectedProfile.name doesn't return
@@ -417,10 +446,6 @@ var ConfigBase = Class("ConfigBase", {
/** @property {string} The Dactyl version string. */
version: Class.Memoize(function () {
if (this.VCSPath)
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
"--template=hg{rev}-{branch}"]).output;
return this.addon.version;
}),
@@ -659,10 +684,13 @@ config.INIT = update(Object.create(config.INIT), config.INIT, {
load: function load(dactyl, modules, window) {
load.superapply(this, arguments);
this.timeout(function () {
if (this.branch && this.branch !== "default" &&
modules.yes_i_know_i_should_not_report_errors_in_these_branches_thanks.indexOf(this.branch) === -1)
dactyl.warn(_("warn.notDefaultBranch", config.appName, this.branch));
this.timeout(() => {
let list = modules.yes_i_know_i_should_not_report_errors_in_these_branches_thanks;
this.branch.then(branch => {
if (branch && branch !== "default" && !list.includes(branch))
dactyl.warn(_("warn.notDefaultBranch", config.appName, branch));
});
}, 1000);
}
});