зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
1fc2cdf98d
Коммит
7482de916e
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class ProtocolFuzzerHelper {
|
|||
|
||||
static void RemoveShmemFromProtocol(IToplevelProtocol* aProtocol,
|
||||
int32_t aId) {
|
||||
aProtocol->mShmemMap.RemoveIfPresent(aId);
|
||||
aProtocol->mShmemMap.Remove(aId);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче