From c982155f21288fecee7b3188c83cb3a0af217eff Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 25 Sep 2011 23:06:48 +0000 Subject: [PATCH] 10-20% speed boost in initial itemTreeView load --- chrome/content/zotero/xpcom/data/items.js | 24 ++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index fcdadf58ce..748bafe85f 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -49,6 +49,11 @@ Zotero.Items = new function() { ['firstCreator', 'numNotes', 'numAttachments'] ); } + + // Once primary fields have been cached, get rid of getter for speed purposes + delete this.primaryFields; + this.primaryFields = _primaryFields; + return _primaryFields; }); @@ -685,28 +690,29 @@ Zotero.Items = new function() { if (arguments[0]) { sql += ' AND I.itemID IN (' + Zotero.join(arguments[0], ',') + ')'; } - var itemsRows = Zotero.DB.query(sql); - var itemIDs = []; - for each(var row in itemsRows) { - var itemID = row.itemID; - itemIDs.push(itemID); + var itemsRows = Zotero.DB.query(sql), + itemIDs = {}; + for(var i=0, n=itemsRows.length; i