Bug 1641090, part 6 - Make ReplaceWithID compatible with nsTHashtable's Put. r=nika

This method is the same as Put(), except that it asserts that the item
is not already present. It also puts the key second. Make it compatible
by hoisting out the assert and reversing the arguments. We can use the
definition of Put() defined in an earlier patch.

Differential Revision: https://phabricator.services.mozilla.com/D77167
This commit is contained in:
Andrew McCreight 2020-05-28 15:55:03 +00:00
parent 7482de916e
commit 5fdbb56cfb
2 changed files with 2 additions and 6 deletions

View File

@ -47,11 +47,6 @@ class IDMap {
}
}
void ReplaceWithID(const T& data, int32_t id) {
MOZ_ASSERT(Contains(id), "Only replace an existing ID");
data_[id] = data;
}
void Clear() { data_.clear(); }
T Lookup(int32_t id) const {

View File

@ -867,7 +867,8 @@ void IToplevelProtocol::ReplaceEventTargetForActor(
MOZ_RELEASE_ASSERT(id != kNullActorId && id != kFreedActorId);
MutexAutoLock lock(mEventTargetMutex);
mEventTargetMap.ReplaceWithID(aEventTarget, id);
MOZ_ASSERT(mEventTargetMap.Contains(id), "Only replace an existing ID");
mEventTargetMap.Put(id, aEventTarget);
}
} // namespace ipc