Bug 476928 - Slow closing of tabs when entering Private Browsing mode. r=dietrich
authorSimon Bünzli <zeniko@gmail.com>
Sat, 07 Mar 2009 14:56:16 +0100
changeset 23694 6f44d1dd4764a24dcd4e0bd089345a546418cf07
parent 23693 0e90aaff293fdae1cf7fd7c79e3de50eed55d79d
child 23695 01c2fd0b1d0ddc63d264c55a38d03f767989b5f5
push id857
push userdgottwald@mozilla.com
push dateSat, 07 Mar 2009 13:57:52 +0000
reviewersdietrich
bugs476928
milestone1.9.1b4pre
Bug 476928 - Slow closing of tabs 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
@@ -1653,18 +1653,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);
     }