mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 21:32:25 +01:00
speed up Struct slightly and don't use it for History for now. (Still doesn't fix all perf problems, as it is still used in many other places like styles).
This commit is contained in:
@@ -549,9 +549,9 @@ function History() //{{{
|
|||||||
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);
|
||||||
|
|
||||||
const History = new Struct("url", "title", "icon");
|
// const History = new Struct("url", "title", "icon");
|
||||||
History.defaultValue("title", function () "[No Title]");
|
// History.defaultValue("title", function () "[No Title]");
|
||||||
History.defaultValue("icon", function () bookmarks.getFavicon(this.url));
|
// History.defaultValue("icon", function () bookmarks.getFavicon(this.url));
|
||||||
|
|
||||||
var placesHistory;
|
var placesHistory;
|
||||||
var cachedHistory = []; // add pages here after loading the initial Places history
|
var cachedHistory = []; // add pages here after loading the initial Places history
|
||||||
@@ -575,7 +575,7 @@ function History() //{{{
|
|||||||
var node = rootNode.getChild(i);
|
var node = rootNode.getChild(i);
|
||||||
// liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
|
// liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
|
||||||
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
|
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!
|
// close a container after using it!
|
||||||
@@ -766,7 +766,7 @@ function History() //{{{
|
|||||||
if (placesHistory.some(function (h) h[0] == url))
|
if (placesHistory.some(function (h) h[0] == url))
|
||||||
placesHistory = placesHistory.filter(filter);
|
placesHistory = placesHistory.filter(filter);
|
||||||
|
|
||||||
cachedHistory.unshift(History(url, title));
|
cachedHistory.unshift({ url: url, title: title, get icon() function() bookmarks.getFavicon(this.url) });
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
function Struct()
|
||||||
{
|
{
|
||||||
let self = this instanceof Struct ? this : new Struct();
|
let self = this instanceof Struct ? this : new Struct();
|
||||||
@@ -503,11 +506,13 @@ function Struct()
|
|||||||
function ConStructor()
|
function ConStructor()
|
||||||
{
|
{
|
||||||
let self = this instanceof arguments.callee ? this : new arguments.callee();
|
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)
|
if (arguments[i] != undefined)
|
||||||
self[k] = v;
|
self[i] = arguments[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
ConStructor.prototype = self;
|
ConStructor.prototype = self;
|
||||||
|
|||||||
Reference in New Issue
Block a user