diff --git a/content/bookmarks.js b/content/bookmarks.js index 8d470c78..b69f047b 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -549,9 +549,9 @@ function History() //{{{ const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"] .getService(Components.interfaces.nsINavHistoryService); - const History = new Struct("url", "title", "icon"); - History.defaultValue("title", function () "[No Title]"); - History.defaultValue("icon", function () bookmarks.getFavicon(this.url)); + // const History = new Struct("url", "title", "icon"); + // History.defaultValue("title", function () "[No Title]"); + // History.defaultValue("icon", function () bookmarks.getFavicon(this.url)); var placesHistory; var cachedHistory = []; // add pages here after loading the initial Places history @@ -575,7 +575,7 @@ function History() //{{{ var node = rootNode.getChild(i); // liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type); if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark - placesHistory.push(History(node.uri, node.title)) + placesHistory.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(this.url) }); } // close a container after using it! @@ -766,7 +766,7 @@ function History() //{{{ if (placesHistory.some(function (h) h[0] == url)) placesHistory = placesHistory.filter(filter); - cachedHistory.unshift(History(url, title)); + cachedHistory.unshift({ url: url, title: title, get icon() function() bookmarks.getFavicon(this.url) }); return true; }, diff --git a/content/util.js b/content/util.js index cb245e03..3517fa4d 100644 --- a/content/util.js +++ b/content/util.js @@ -485,6 +485,9 @@ const util = { //{{{ } }; //}}} +// Struct is really slow, AT LEAST 5 times slower than using structs or simple Objects +// main reason is the function ConStructor(), which i couldn't get faster. +// Maybe it's a TraceMonkey problem, for now don't use it for anything which must be fast (like bookmarks or history) function Struct() { let self = this instanceof Struct ? this : new Struct(); @@ -503,11 +506,13 @@ function Struct() function ConStructor() { let self = this instanceof arguments.callee ? this : new arguments.callee(); - for (let [k, v] in Iterator(Array.slice(arguments))) + //for (let [k, v] in Iterator(Array.slice(arguments))) // That is makes using struct twice as slow as the following code: + for (let i = 0; i < arguments.length; i++) { - if (v != undefined) - self[k] = v; + if (arguments[i] != undefined) + self[i] = arguments[i]; } + return self; } ConStructor.prototype = self;