Skip to content

Commit adb1860

Browse files
committed
Address comments
1 parent 2009ff9 commit adb1860

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lldb/source/Core/ModuleList.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,9 @@ class SharedModuleList {
894894

895895
void RemoveFromMap(const Module *module_ptr, bool if_orphaned = false) {
896896
ConstString name = module_ptr->GetFileSpec().GetFilename();
897-
auto it = m_name_to_modules.find(name);
898-
if (it == m_name_to_modules.end())
897+
if (m_name_to_modules.contains(name))
899898
return;
900-
llvm::SmallVectorImpl<ModuleSP> &vec = it->second;
899+
llvm::SmallVectorImpl<ModuleSP> &vec = m_name_to_modules[name];
901900
for (auto *it = vec.begin(); it != vec.end(); ++it) {
902901
if (it->get() == module_ptr) {
903902
// use_count == 2 means only held by map and list (orphaned)
@@ -930,12 +929,9 @@ class SharedModuleList {
930929
module_sp->GetPlatformFileSpec();
931930

932931
llvm::SmallVectorImpl<ModuleSP> &vec = it->second;
933-
// Iterate backwards to minimize element shifting during removal.
934-
for (int i = vec.size() - 1; i >= 0; --i) {
935-
auto *it = vec.begin() + i;
936-
if ((*it)->MatchesModuleSpec(equivalent_module_spec))
937-
vec.erase(it);
938-
}
932+
llvm::erase_if(vec, [&equivalent_module_spec](ModuleSP &element) {
933+
return element->MatchesModuleSpec(equivalent_module_spec);
934+
});
939935
}
940936

941937
/// Remove orphans from the vector.

0 commit comments

Comments
 (0)