1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 15:22:26 +01:00

use history cache for newly opened pages

This commit is contained in:
Martin Stubenschrott
2008-08-16 10:38:00 +00:00
parent 3f5f7ee214
commit 4688d989f7
2 changed files with 14 additions and 8 deletions

View File

@@ -483,7 +483,8 @@ liberator.History = function () //{{{
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService);
var history = null;
var history = [];
var cachedHistory = []; // add pages here after loading the initial Places history
if (liberator.options["preload"])
setTimeout(function () { load(); }, 100);
@@ -652,7 +653,8 @@ liberator.History = function () //{{{
if (!history)
load();
return liberator.completion.filterURLArray(history, filter);
return liberator.completion.filterURLArray(cachedHistory, filter).concat(
liberator.completion.filterURLArray(history, filter));
},
// the history is automatically added to the Places global history
@@ -662,11 +664,16 @@ liberator.History = function () //{{{
if (!history)
load();
history = history.filter(function (elem) {
return elem[0] != url;
});
// don' let cachedHistory grow too large
if (cachedHistory.length > 1000)
{
history = cachedHistory.concat(history);
cachedHistory = [];
}
else
cachedHistory = cachedHistory.filter(function (elem) { return elem[0] != url; });
history.unshift([url, title || "[No title]"]);
cachedHistory.unshift([url, title || "[No title]"]);
return true;
},
@@ -740,7 +747,6 @@ liberator.History = function () //{{{
}
else
{
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
for (var i = 0; i < items.length; i++)
@@ -755,7 +761,6 @@ liberator.History = function () //{{{
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
}
}
};
//}}}
}; //}}}