mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-10 22:35:46 +01:00
Precompute completion string matching function.
This commit is contained in:
@@ -17,7 +17,7 @@ let currentModule;
|
||||
function defmodule(name, module, params) {
|
||||
module.NAME = name;
|
||||
module.EXPORTED_SYMBOLS = params.exports || [];
|
||||
dump("defmodule " + name + "\n");
|
||||
defmodule.loadLog.push("defmodule " + name);
|
||||
for(let [, mod] in Iterator(params.require || []))
|
||||
require(module, mod);
|
||||
|
||||
@@ -30,10 +30,22 @@ function defmodule(name, module, params) {
|
||||
}
|
||||
currentModule = module;
|
||||
}
|
||||
defmodule.loadLog = [];
|
||||
// Object.defineProperty(defmodule.loadLog, "push", { value: function (val) { dump(val + "\n"); this[this.length] = val } });
|
||||
defmodule.modules = [];
|
||||
defmodule.times = {};
|
||||
defmodule.time = function (major, minor, func, self) {
|
||||
let time = Date.now();
|
||||
let res = func.apply(self, Array.slice(arguments, 4));
|
||||
let delta = Date.now() - time;
|
||||
defmodule.times[major] = (defmodule.times[major] || 0) + delta;
|
||||
if (minor)
|
||||
defmodule.times[major + ":" + minor] = (defmodule.times[major + ":" + minor] || 0) + delta;
|
||||
return res;
|
||||
}
|
||||
|
||||
function endmodule() {
|
||||
dump("endmodule " + currentModule.NAME + "\n");
|
||||
defmodule.loadLog.push("endmodule " + currentModule.NAME);
|
||||
loaded[currentModule.NAME] = 1;
|
||||
for(let [, mod] in Iterator(use[currentModule.NAME] || []))
|
||||
require(mod, currentModule.NAME, "use");
|
||||
@@ -41,7 +53,7 @@ function endmodule() {
|
||||
|
||||
function require(obj, name, from) {
|
||||
try {
|
||||
dump((from || "require") + ": loading " + name + " into " + obj.NAME + "\n");
|
||||
defmodule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
|
||||
Cu.import("resource://dactyl/" + name + ".jsm", obj);
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
@@ -699,12 +699,11 @@ const Util = Module("Util", {
|
||||
if (!re.global)
|
||||
re = RegExp(re.source || re, "g");
|
||||
let match, start = 0, res = [];
|
||||
while ((match = re.exec(str)) && --limit && match[0].length) {
|
||||
while (--limit && (match = re.exec(str)) && match[0].length) {
|
||||
res.push(str.substring(start, match.index));
|
||||
start = match.index + match[0].length;
|
||||
}
|
||||
if (limit)
|
||||
res.push(str.substring(start));
|
||||
res.push(str.substring(start));
|
||||
return res;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user