Bug 1641090, part 5 - Make IDMap::Remove match nsTHashtable's behavior. r=nika

nsTHashtable::Remove doesn't assert if the item isn't present. Match that
behavior by removing the assert and putting it at all of the call sites.

This just turns IDMap::Remove into RemoveIfPresent, so merge them.

Differential Revision: https://phabricator.services.mozilla.com/D77166
This commit is contained in:
Andrew McCreight 2020-05-27 23:59:34 +00:00
Родитель 4e909e4e75
Коммит de620fecfb
2 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -41,15 +41,6 @@ class IDMap {
void Put(int32_t id, const T& data) { data_[id] = data; }
void Remove(int32_t id) {
iterator i = data_.find(id);
if (i == data_.end()) {
NOTREACHED() << "Attempting to remove an item not in the list";
return;
}
data_.erase(i);
}
void RemoveIfPresent(int32_t id) {
iterator i = data_.find(id);
if (i != data_.end()) {
data_.erase(i);

Просмотреть файл

@ -673,10 +673,12 @@ IProtocol* IToplevelProtocol::Lookup(int32_t aId) {
}
void IToplevelProtocol::Unregister(int32_t aId) {
MOZ_ASSERT(mActorMap.Contains(aId),
"Attempting to remove an ID not in the actor map");
mActorMap.Remove(aId);
MutexAutoLock lock(mEventTargetMutex);
mEventTargetMap.RemoveIfPresent(aId);
mEventTargetMap.Remove(aId);
}
Shmem::SharedMemory* IToplevelProtocol::CreateSharedMemory(
@ -737,6 +739,8 @@ bool IToplevelProtocol::DestroySharedMemory(Shmem& shmem) {
Message* descriptor =
shmem.UnshareFrom(Shmem::PrivateIPDLCaller(), MSG_ROUTING_CONTROL);
MOZ_ASSERT(mShmemMap.Contains(aId),
"Attempting to remove an ID not in the shmem map");
mShmemMap.Remove(aId);
Shmem::Dealloc(Shmem::PrivateIPDLCaller(), segment);
@ -778,6 +782,8 @@ bool IToplevelProtocol::ShmemDestroyed(const Message& aMsg) {
Shmem::SharedMemory* rawmem = LookupSharedMemory(id);
if (rawmem) {
MOZ_ASSERT(mShmemMap.Contains(id),
"Attempting to remove an ID not in the shmem map");
mShmemMap.Remove(id);
Shmem::Dealloc(Shmem::PrivateIPDLCaller(), rawmem);
}