From 7d4d4d0296b9ae35b1b47992413a4ba0ae5483a8 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 17 Feb 2014 13:16:38 -0800 Subject: [PATCH] Use cache for `literal()` calls. --- common/modules/base.jsm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 9424141a..b8e0cedc 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -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);