Closed Bug 817373 Opened 12 years ago Closed 11 years ago

tabbox's selectedItem induces O(N^2) type algorithms with e.g. panorama

Categories

(Toolkit :: UI Widgets, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 822914

People

(Reporter: glandium, Unassigned)

Details

(Whiteboard: [Snappy:?])

When opening Panorama for the first time, GroupItems initializes. For each tab, there is a "tab == gBrowser.selectedTab" test, and gBrowser.selectedTab ends up in tabbox's selectedItem, which goes through all tabs to see if the selected flag is set. This is O(N^2), and makes opening panorama take more than 10s on my (crazy) 1400 tabs window, entirely blocking the UI. See the profile on http://bit.ly/SDB0KB

Arguably, the Panorama code could be checking the selected flag directly, but i guess tabbox's goal is to hide this implementation detail...
Whiteboard: [Snappy:?]
I agree, that's horrible but gBrowser.selectedTab is a quite old API. Is there no cache for that property? We certainly don't need to iterate over all tabs every time we access it.
(In reply to Mike Hommey [:glandium] from comment #0)
> When opening Panorama for the first time, GroupItems initializes. For each
> tab, there is a "tab == gBrowser.selectedTab" test, and gBrowser.selectedTab
> ends up in tabbox's selectedItem, which goes through all tabs to see if the
> selected flag is set.

https://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml#2155

gBrowser.selectedTab does not iterate over all tabs, afaict. Am I missing something here?
(In reply to Tim Taubert [:ttaubert] from comment #2)
> https://mxr.mozilla.org/mozilla-central/source/browser/base/content/
> tabbrowser.xml#2155
> 
> gBrowser.selectedTab does not iterate over all tabs, afaict. Am I missing
> something here?

bug 822914, apparently :)
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
Although arguably, tabbox's selectedItem is still awful.
You need to log in before you can comment on or make changes to this bug.