зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1684965 - [devtools] Manage a reference to the parent in Pool. r=ochameau.
At the moment, the `getParent` method was using the connection `poolFor` method to retrieve the pool that was managing it. This is quite costly as `poolFor` loops through all the pools of the connection. This patch adds a `parentPool` property to the Pool that is set in `manage` and reset in `unmanage`, and used in the `getParent` method. This speeds up getParent as well as the methods that call it (`manage` when the actor was already managed, and `destroy`). Differential Revision: https://phabricator.services.mozilla.com/D100981
This commit is contained in:
Родитель
3815a47abb
Коммит
d72cf4ca31
|
@ -30,14 +30,16 @@ class Pool extends EventEmitter {
|
|||
this.conn = conn;
|
||||
}
|
||||
this.label = label;
|
||||
this.__poolMap = null;
|
||||
}
|
||||
|
||||
__poolMap = null;
|
||||
parentPool = null;
|
||||
|
||||
/**
|
||||
* Return the parent pool for this client.
|
||||
*/
|
||||
getParent() {
|
||||
return this.conn.poolFor(this.actorID);
|
||||
return this.parentPool;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +95,7 @@ class Pool extends EventEmitter {
|
|||
}
|
||||
}
|
||||
this._poolMap.set(actor.actorID, actor);
|
||||
actor.parentPool = this;
|
||||
}
|
||||
|
||||
unmanageChildren(FrontType) {
|
||||
|
@ -107,7 +110,11 @@ class Pool extends EventEmitter {
|
|||
* Remove an actor as a child of this pool.
|
||||
*/
|
||||
unmanage(actor) {
|
||||
this.__poolMap && this.__poolMap.delete(actor.actorID);
|
||||
if (!this.__poolMap) {
|
||||
return;
|
||||
}
|
||||
this.__poolMap.delete(actor.actorID);
|
||||
actor.parentPool = null;
|
||||
}
|
||||
|
||||
// true if the given actor ID exists in the pool.
|
||||
|
|
Загрузка…
Ссылка в новой задаче