Skip to content

Commit bad04dc

Browse files
[lldb] Avoid repeated hash lookups (NFC) (#112301)
1 parent cb3e7b3 commit bad04dc

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lldb/include/lldb/Breakpoint/StopPointSiteList.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,10 @@ template <typename StopPointSite> class StopPointSiteList {
3838
typename StopPointSite::SiteID Add(const StopPointSiteSP &site_sp) {
3939
lldb::addr_t site_load_addr = site_sp->GetLoadAddress();
4040
std::lock_guard<std::recursive_mutex> guard(m_mutex);
41-
typename collection::iterator iter = m_site_list.find(site_load_addr);
42-
4341
// Add site to the list. However, if the element already exists in
4442
// the list, then we don't add it, and return InvalidSiteID.
45-
if (iter == m_site_list.end()) {
46-
m_site_list[site_load_addr] = site_sp;
47-
return site_sp->GetID();
48-
} else {
49-
return UINT32_MAX;
50-
}
43+
bool inserted = m_site_list.try_emplace(site_load_addr, site_sp).second;
44+
return inserted ? site_sp->GetID() : UINT32_MAX;
5145
}
5246

5347
/// Standard Dump routine, doesn't do anything at present.

0 commit comments

Comments
 (0)