mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:12:26 +01:00
Cleaner javascript completion caching.
This commit is contained in:
@@ -26,6 +26,13 @@ the provisions above, a recipient may use your version of this file under
|
|||||||
the terms of any one of the MPL, the GPL or the LGPL.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
|
// An eval with a cleaner lexical scope.
|
||||||
|
const EVAL_TMP = "__liberator_eval_tmp";
|
||||||
|
function __eval(__liberator_eval_arg, __liberator_eval_tmp)
|
||||||
|
{
|
||||||
|
return window.eval(__liberator_eval_arg);
|
||||||
|
}
|
||||||
|
|
||||||
function Completion() //{{{
|
function Completion() //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -172,7 +179,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.eval = function eval(arg, key)
|
this.eval = function eval(arg, key, tmp)
|
||||||
{
|
{
|
||||||
if (!("eval" in cacheResults))
|
if (!("eval" in cacheResults))
|
||||||
cacheResults.eval = {};
|
cacheResults.eval = {};
|
||||||
@@ -184,7 +191,7 @@ function Completion() //{{{
|
|||||||
return cache[key];
|
return cache[key];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return cache[key] = window.eval(arg);
|
return cache[key] = __eval(arg, tmp);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -365,10 +372,9 @@ function Completion() //{{{
|
|||||||
// we'll still use the old value. But, it's worth it.
|
// we'll still use the old value. But, it's worth it.
|
||||||
let getObj = function (frame, stop)
|
let getObj = function (frame, stop)
|
||||||
{
|
{
|
||||||
const TMP = "__liberator_eval_tmp";
|
|
||||||
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
||||||
let prev = statement;
|
let prev = statement;
|
||||||
window[TMP] = null;
|
let obj;
|
||||||
for (let [i, dot] in Iterator(get(frame)[DOTS]))
|
for (let [i, dot] in Iterator(get(frame)[DOTS]))
|
||||||
{
|
{
|
||||||
if (dot < statement)
|
if (dot < statement)
|
||||||
@@ -379,9 +385,9 @@ function Completion() //{{{
|
|||||||
if (prev != statement)
|
if (prev != statement)
|
||||||
s = TMP + "." + s;
|
s = TMP + "." + s;
|
||||||
prev = dot + 1;
|
prev = dot + 1;
|
||||||
window[TMP] = self.eval(s, str.substring(statement, dot));
|
obj = self.eval(s, str.substring(statement, dot), obj);
|
||||||
}
|
}
|
||||||
return window[TMP];
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
let getObjKey = function (frame)
|
let getObjKey = function (frame)
|
||||||
|
|||||||
Reference in New Issue
Block a user