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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user