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

Turn JS completion caching back on

This commit is contained in:
Kris Maglione
2008-11-22 20:58:56 +00:00
parent 5db27607ad
commit 76a5b4cf7a
3 changed files with 42 additions and 41 deletions

View File

@@ -76,7 +76,6 @@ function Bookmarks() //{{{
let uri = ioService.newURI(node.uri, null, null);
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
let tags = taggingService.getTagsForURI(uri, {}) || [];
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
}

View File

@@ -68,6 +68,7 @@ function CompletionContext(editor, name, offset)
this.reset();
}
this.name = name || "";
this.cache = {};
this._items = []; // FIXME
this.selectionTypes = {};
}
@@ -266,19 +267,19 @@ function Completion() //{{{
completion.filterMap = [null, function (v) template.highlight(v, true)];
//if (cacheFilter.js === cacheKey)
// return cacheResults.js;
//cacheFilter.js = cacheKey;
let [obj, key] = objects;
let cache = this.context.cache.objects || {};
this.context.cache.objects = cache;
if (key in cache)
return cache[key];
// Can't use the cache. Build a member list.
compl = [];
for (let [,obj] in Iterator(objects))
{
let compl = [];
// Things we can dereference
if (["object", "string", "function"].indexOf(typeof obj) == -1)
continue;
return [];
if (!obj)
continue;
return [];
// XPCNativeWrappers, etc, don't show all accessible
// members until they're accessed, so, we look at
@@ -294,9 +295,8 @@ function Completion() //{{{
// return that, too.
if (orig.wrappedJSObject)
compl.push([["wrappedJSObject", obj]]);
}
compl = util.Array.flatten(compl);
return cacheResults.js = compl;
return cache[key] = compl;
}
this.filter = function filter(compl, key, last, offset)
@@ -327,9 +327,9 @@ function Completion() //{{{
this.eval = function eval(arg, key, tmp)
{
if (!("eval" in cacheResults))
cacheResults.eval = {};
let cache = cacheResults.eval;
if (!("eval" in this.context.cache))
this.context.cache.eval = {};
let cache = this.context.cache.eval;
if (!key)
key = arg;
@@ -525,6 +525,7 @@ function Completion() //{{{
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
let prev = statement;
let obj;
let cacheKey;
for (let [i, dot] in Iterator(get(frame)[DOTS].concat(stop)))
{
if (dot < statement)
@@ -538,7 +539,7 @@ function Completion() //{{{
cacheKey = str.substring(statement, dot);
obj = self.eval(s, cacheKey, obj);
}
return [[obj, str.substring(statement, stop + 1)]];
return [[obj, cacheKey]]
}
function getObjKey(frame)
@@ -565,7 +566,7 @@ function Completion() //{{{
{
let ctxt = this.context.fork(obj[1], top[OFFSET]);
ctxt.title = [obj[1]];
ctxt.items = this.filter(compl || this.objectKeys(obj[0]), key + (string || ""), last, key.length);
ctxt.items = this.filter(compl || this.objectKeys(obj), key + (string || ""), last, key.length);
}
}
@@ -627,7 +628,7 @@ function Completion() //{{{
try
{
var completer = obj[func].liberatorCompleter;
var completer = obj[0][0][func].liberatorCompleter;
}
catch (e) {}
if (!completer)
@@ -645,10 +646,11 @@ function Completion() //{{{
});
args.push(key);
let compl = completer.call(this, func, obj, string, args);
let compl = completer.call(this, func, obj[0][0], string, args);
if (!(compl instanceof Array))
compl = [v for (v in compl)];
key = this.eval(key);
obj[0][1] += "." + func + "(...";
return complete.call(this, obj, key, compl, string, last);
}

View File

@@ -383,7 +383,10 @@ const liberator = (function () //{{{
{
args = args.string;
let method = args[0] == ":" ? "execute" : "eval";
if (args[0] == ":")
var method = function () liberator.execute(args);
else
method = liberator.eval("(function () {" + args + "})");
try
{
@@ -395,7 +398,7 @@ const liberator = (function () //{{{
for (let i in util.interruptableRange(0, count, 500))
{
let now = Date.now();
liberator[method](args);
method();
total += Date.now() - now;
}
@@ -437,10 +440,7 @@ const liberator = (function () //{{{
else
{
var beforeTime = Date.now();
if (args && args[0] == ":")
liberator.execute(args);
else
liberator.eval(args);
method();
if (special)
return;