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

RESOLVED DUPLICATE of bug 822914

Status

()

Toolkit
XUL Widgets
RESOLVED DUPLICATE of bug 822914
5 years ago
5 years ago

People

(Reporter: glandium, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [Snappy:?])

(Reporter)

Description

5 years ago
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...
(Reporter)

Updated

5 years ago
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?
(Reporter)

Comment 3

5 years ago
(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
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 822914
(Reporter)

Comment 4

5 years ago
Although arguably, tabbox's selectedItem is still awful.
You need to log in before you can comment on or make changes to this bug.