mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 19:52:26 +01:00
Speed up JS completion a bit more
This commit is contained in:
@@ -80,13 +80,14 @@ function Completion() //{{{
|
|||||||
let last = ""; /* The last opening char pushed onto the stack. */
|
let last = ""; /* The last opening char pushed onto the stack. */
|
||||||
let lastNonwhite = ""; /* Last non-whitespace character we saw. */
|
let lastNonwhite = ""; /* Last non-whitespace character we saw. */
|
||||||
let lastChar = ""; /* Last character we saw, used for \ escaping quotes. */
|
let lastChar = ""; /* Last character we saw, used for \ escaping quotes. */
|
||||||
let lastKey = null;
|
|
||||||
let compl = [];
|
let compl = [];
|
||||||
let str = "";
|
let str = "";
|
||||||
|
|
||||||
let lastIdx = 0;
|
let lastIdx = 0;
|
||||||
let continuing = false;
|
let continuing = false;
|
||||||
|
|
||||||
|
let cacheKey = null;
|
||||||
|
|
||||||
this.completers = {};
|
this.completers = {};
|
||||||
|
|
||||||
this.iter = function iter(obj)
|
this.iter = function iter(obj)
|
||||||
@@ -136,6 +137,10 @@ function Completion() //{{{
|
|||||||
if (!(objects instanceof Array))
|
if (!(objects instanceof Array))
|
||||||
objects = [objects];
|
objects = [objects];
|
||||||
|
|
||||||
|
if (cacheFilter.js === cacheKey)
|
||||||
|
return cacheResults.js;
|
||||||
|
cacheFilter.js = cacheKey;
|
||||||
|
|
||||||
// Can't use the cache. Build a member list.
|
// Can't use the cache. Build a member list.
|
||||||
compl = [];
|
compl = [];
|
||||||
for (let [,obj] in Iterator(objects))
|
for (let [,obj] in Iterator(objects))
|
||||||
@@ -149,7 +154,7 @@ function Completion() //{{{
|
|||||||
for (let [k, v] in this.iter(obj))
|
for (let [k, v] in this.iter(obj))
|
||||||
compl.push([k, template.highlight(v, true)]);
|
compl.push([k, template.highlight(v, true)]);
|
||||||
}
|
}
|
||||||
return compl;
|
return cacheResults.js = compl;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filter = function filter(compl, key, last, offset)
|
this.filter = function filter(compl, key, last, offset)
|
||||||
@@ -177,7 +182,6 @@ function Completion() //{{{
|
|||||||
res = res.filter(function isIdent(a) /^[\w$][\w\d$]*$/.test(a[0]));
|
res = res.filter(function isIdent(a) /^[\w$][\w\d$]*$/.test(a[0]));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.eval = function eval(arg, key, tmp)
|
this.eval = function eval(arg, key, tmp)
|
||||||
@@ -386,7 +390,8 @@ function Completion() //{{{
|
|||||||
if (prev != statement)
|
if (prev != statement)
|
||||||
s = EVAL_TMP + "." + s;
|
s = EVAL_TMP + "." + s;
|
||||||
prev = dot + 1;
|
prev = dot + 1;
|
||||||
obj = self.eval(s, str.substring(statement, dot), obj);
|
cacheKey = str.substring(statement, dot);
|
||||||
|
obj = self.eval(s, cacheKey, obj);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -397,6 +402,7 @@ function Completion() //{{{
|
|||||||
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
||||||
let end = (frame == -1 ? lastIdx : get(frame + 1)[OFFSET]);
|
let end = (frame == -1 ? lastIdx : get(frame + 1)[OFFSET]);
|
||||||
|
|
||||||
|
cacheKey = null;
|
||||||
let obj = [liberator, window]; // Default objects;
|
let obj = [liberator, window]; // Default objects;
|
||||||
/* Is this an object dereference? */
|
/* Is this an object dereference? */
|
||||||
if (dot < statement) // No.
|
if (dot < statement) // No.
|
||||||
|
|||||||
Reference in New Issue
Block a user