Open Bug 1651388 Opened 5 years ago Updated 5 years ago

Avoid looping on poolChildren to find existing targets managed by a WatcherFront

Categories

(DevTools :: Inspector, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: jdescottes, Unassigned)

References

Details

From a comment by :ochameau made for the review of Bug 1647366.

[...] I was wondering if we could improve the existing code (i.e. everything else in this method)
But do you think we could either:

  • somehow replace Pool's map with something custom, where we store the BrowsingContextTarget in a Map keyed by BrowsingContext ID ?
  • if not possible, have such Map, duplicating the content of Pool's one, onto Watcher or TargetList (TargetList isn't easilly accessible from Front :/)

Everytime I see this for loop on pool's map... I want to try to tweak Pool!

The code we are talking about here is WatcherFront::getBrowsingContextTarget and especially the following loop

    // First scan the watcher children as the watcher manages all the targets
    for (const front of this.poolChildren()) {
      if (front.browsingContextID == id) {
        return front;
      }
    }
You need to log in before you can comment on or make changes to this bug.