1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 03:02:27 +01:00

changed horrible history cache code

This commit is contained in:
Martin Stubenschrott
2008-11-13 23:19:13 +00:00
parent 1f056ad06c
commit 05a699dc53

View File

@@ -750,22 +750,18 @@ function History() //{{{
// so just update our cached history here
add: function (url, title)
{
if (!placesHistory)
load();
let filter = function (h) h[0] != url;
// don't let cachedHistory grow too large
if (cachedHistory.length > 1000)
if (placesHistory && cachedHistory.length > 1000)
{
placesHistory = cachedHistory.concat(placesHistory);
placesHistory = placesHistory.filter(filter);
cachedHistory = [];
}
else
cachedHistory = cachedHistory.filter(filter);
if (placesHistory.some(function (h) h[0] == url))
placesHistory = placesHistory.filter(filter);
cachedHistory.unshift({ url: url, title: title, get icon() function() bookmarks.getFavicon(this.url) });
return true;
},