Bug 1473513 - reduce number of poolFor calls; r=ochameau

Summary:
MozReview-Commit-ID: 9VqKPauAP9j

Depends on D6475

Reviewers: ochameau

Reviewed By: ochameau

Bug #: 1473513

Differential Revision: https://phabricator.services.mozilla.com/D6476

--HG--
extra : rebase_source : 1bebc34bf805dfcf7bce0b5d8f3a2a13bab11173
This commit is contained in:
yulia 2018-09-26 10:08:10 +02:00
parent dd29e366ea
commit c6dbe43c8e

View File

@ -859,16 +859,18 @@ Pool.prototype = extend(EventEmitter.prototype, {
manage: function(actor) {
if (!actor.actorID) {
actor.actorID = this.conn.allocID(actor.actorPrefix || actor.typeName);
}
} else {
// If the actor is already registerd in a pool, remove it without destroying it.
// This happens for example when an addon is reloaded. To see this behavior, take a
// look at devtools/server/tests/unit/test_addon_reload.js
// If the actor is already in a pool, remove it without destroying it.
// TODO: not all actors have been moved to protocol.js, so they do not all have
// a parent field. Remove the check for the parent once the conversion is finished
const parent = this.poolFor(actor.actorID);
if (parent) {
parent.unmanage(actor);
// TODO: not all actors have been moved to protocol.js, so they do not all have
// a parent field. Remove the check for the parent once the conversion is finished
const parent = this.poolFor(actor.actorID);
if (parent) {
parent.unmanage(actor);
}
}
this._poolMap.set(actor.actorID, actor);
return actor;
},