1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 23: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

1
NEWS
View File

@@ -15,6 +15,7 @@
generous donation which made this behavior possible) generous donation which made this behavior possible)
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
too unpredictable too unpredictable
* performance fix by using cached history, should save about 5ms on each pageload
* add :emenu for accessing the Firefox main menu items from the command line * add :emenu for accessing the Firefox main menu items from the command line
* add 'shell' and 'shellcmdflag' options * add 'shell' and 'shellcmdflag' options
* :tabprevious, :bprevious, :tabnext, :bnext and friends now accept a prefix count * :tabprevious, :bprevious, :tabnext, :bnext and friends now accept a prefix count

View File

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