Bug 476928 - Slow closing of tabs with the given testcase when entering Private Browsing mode. r=dietrich
authorSimon Bünzli <zeniko@gmail.com>
Sun, 22 Feb 2009 09:47:31 +0100
changeset 25365 035de2805eee8b769b4202add59ec9fc2f13c65b
parent 25364 0bc0ee3c2964b2a7f95c2c67e78a229f642edc1d
child 25366 d1bff51e9ed3b3d209c9c908770a30e65d7748bc
push id5519
push userdgottwald@mozilla.com
push dateSun, 22 Feb 2009 08:52:33 +0000
treeherdermozilla-central@3368baff687b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs476928
milestone1.9.2a1pre
Bug 476928 - Slow closing of tabs with the given testcase when entering Private Browsing mode. r=dietrich
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -1654,18 +1654,19 @@ SessionStoreService.prototype = {
       tabs.push(t < openTabCount ? tabbrowser.mTabs[t] : tabbrowser.addTab());
       // when resuming at startup: add additionally requested pages to the end
       if (!aOverwriteTabs && root._firstTabs) {
         tabbrowser.moveTabTo(tabs[t], t);
       }
     }
 
     // when overwriting tabs, remove all superflous ones
-    for (t = openTabCount - 1; t >= newTabCount; t--) {
-      tabbrowser.removeTab(tabbrowser.mTabs[t]);
+    if (aOverwriteTabs && newTabCount < openTabCount) {
+      Array.slice(tabbrowser.mTabs, newTabCount, openTabCount)
+           .forEach(tabbrowser.removeTab, tabbrowser);
     }
     
     if (aOverwriteTabs) {
       this.restoreWindowFeatures(aWindow, winData);
     }
     if (winData.cookies) {
       this.restoreCookies(winData.cookies);
     }