mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-16 17:43:37 +02:00
Use cache for literal() calls.
This commit is contained in:
@@ -213,20 +213,9 @@ function literal(/* comment */) {
|
|||||||
|
|
||||||
let file = caller.filename.replace(/.* -> /, "");
|
let file = caller.filename.replace(/.* -> /, "");
|
||||||
let key = "literal:" + file + ":" + caller.lineNumber;
|
let key = "literal:" + file + ":" + caller.lineNumber;
|
||||||
if (hasOwnProperty(literal.locations, key))
|
return cache.get(key, function() {
|
||||||
return literal.locations[key];
|
let source = literal.files[file] || File.readURL(file);
|
||||||
|
literal.files[file] = source;
|
||||||
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);
|
|
||||||
|
|
||||||
let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
|
let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
|
||||||
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);
|
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);
|
||||||
|
|||||||
Reference in New Issue
Block a user