Closed Bug 1450572 Opened 3 years ago Closed 3 years ago

Optimize windows.get

Categories

(WebExtensions :: General, enhancement)

enhancement
Not set
normal

Tracking

(firefox61 fixed)

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: Oriol, Assigned: Oriol)

Details

Attachments

(1 file)

browser.windows.get(windowId) is slow if there are lots of windows:

    for (let window of this.browserWindows(true)) {
      if (this.getId(window) === id) {
        return window;
      }
    }

https://searchfox.org/mozilla-central/rev/0e8eb01368600eb552dd558c83c64a3b6a0b89b8/toolkit/components/extensions/parent/ext-tabs-base.js#1392-1396

This should be optimized. This will also benefit browser.tabs.query({windowId}) via bug 1445316.
Comment on attachment 8964184 [details]
Bug 1450572 - Optimize windows.get(windowId)

https://reviewboard.mozilla.org/r/232932/#review238882
Attachment #8964184 - Flags: review?(mixedpuppy) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/57d58de5d58d
Optimize windows.get(windowId) r=mixedpuppy
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/57d58de5d58d
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Is manual testing required on this bug? If yes, please provide some STR and the proper extension(if required) or set the “qe-verify -“ flag.

Thanks!
Flags: needinfo?(oriol-bugzilla)
No difference in behavior, it's just that now the code does not iterate all windows in order to find the desired one. It's observable via performance.now() with lots of windows, but manual testing doesn't seem necessary.
Flags: needinfo?(oriol-bugzilla) → qe-verify-
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.