Closed Bug 1808784 Opened 2 years ago Closed 2 years ago

Cache gBrowser.tabContainer.allTabs instead of gBrowser.tabs

Categories

(Firefox :: Tabbed Browser, task)

task

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: Oriol, Assigned: Oriol)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

gBrowser.tabs is cached:

    get tabs() {
      if (!this._tabs) {
        this._tabs = this.tabContainer.allTabs;
      }
      return this._tabs;
    },

However, some tabContainer code accesses allTabs directly, which is not cached.

It seems to me that gBrowser.tabContainer.allTabs should be cached, and gBrowser.tabs should just redirect to gBrowser.tabContainer.allTabs.

I haven't identified a case where this causes perf problems, but it's a trivial refactoring.

gBrowser.tabs was either redirecting to gBrowser.tabContainer.allTabs or
using the previously cached result. However, most tabContainer code uses
allTabs directly, which was not benefiting from the cache.

Therefore, this patch caches gBrowser.tabContainer.allTabs, and makes
gBrowser.tabs always redirect to it.

Also makes it consistent for gBrowser.tabContainer._getVisibleTabs() and
gBrowser.visibleTabs. In that case both the logic and the cache were in
gBrowser, and tabContainer was redirecting to that, except when gBrowser
hadn't been initialized.

So it's better to have both the logic and the cache in tabContainer.

Assignee: nobody → oriol-bugzilla
Status: NEW → ASSIGNED

D166962 is moving the cache into gBrowser.tabContainer, so the methods
for invalidating it should also be there.

Depends on D166962

Pushed by oriol-bugzilla@hotmail.com: https://hg.mozilla.org/integration/autoland/rev/f64ced636854 Move tab invalidation methods to gBrowser.tabContainer. r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
Blocks: 1808734
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: