1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 18:04:14 +01:00

Use cache for literal() calls.

This commit is contained in:
Kris Maglione
2014-02-17 13:16:38 -08:00
parent 3d925be093
commit 7d4d4d0296

View File

@@ -213,20 +213,9 @@ function literal(/* comment */) {
let file = caller.filename.replace(/.* -> /, "");
let key = "literal:" + file + ":" + caller.lineNumber;
if (hasOwnProperty(literal.locations, key))
return literal.locations[key];
let source = literal.files[file] || File.readURL(file);
literal.files[file] = source;
let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);
return literal.locations[key] = match[1];
// Later...
return cache.get(key, function () {
let source = cache.get("literal:" + file,
() => util.httpGet(file).responseText);
return cache.get(key, function() {
let source = literal.files[file] || File.readURL(file);
literal.files[file] = source;
let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);