Bug 1641090, part 2 - Inline IDMap::HasData. r=nika

It is only used in one place, so get rid of it. Also, iterate in a nicer way.

Differential Revision: https://phabricator.services.mozilla.com/D77163
This commit is contained in:
Andrew McCreight 2020-05-28 15:54:54 +00:00
parent 077aa3dc7e
commit a00f6161a9
2 changed files with 8 additions and 11 deletions

View File

@ -66,13 +66,6 @@ class IDMap {
void Clear() { data_.clear(); }
bool HasData(const T& data) const {
// XXX would like to use <algorithm> here ...
for (const_iterator it = begin(); it != end(); ++it)
if (data == it->second) return true;
return false;
}
T Lookup(int32_t id) const {
const_iterator i = data_.find(id);
if (i == data_.end()) return T();

View File

@ -715,7 +715,12 @@ Shmem::SharedMemory* IToplevelProtocol::LookupSharedMemory(Shmem::id_t aId) {
}
bool IToplevelProtocol::IsTrackingSharedMemory(Shmem::SharedMemory* segment) {
return mShmemMap.HasData(segment);
for (const auto& iter : mShmemMap) {
if (segment == iter.second) {
return true;
}
}
return false;
}
bool IToplevelProtocol::DestroySharedMemory(Shmem& shmem) {
@ -741,9 +746,8 @@ bool IToplevelProtocol::DestroySharedMemory(Shmem& shmem) {
}
void IToplevelProtocol::DeallocShmems() {
for (IDMap<SharedMemory*>::const_iterator cit = mShmemMap.begin();
cit != mShmemMap.end(); ++cit) {
Shmem::Dealloc(Shmem::PrivateIPDLCaller(), cit->second);
for (const auto& cit : mShmemMap) {
Shmem::Dealloc(Shmem::PrivateIPDLCaller(), cit.second);
}
mShmemMap.Clear();
}