Skip to content

Commit d839c06

Browse files
[lldb] Avoid repeated map lookups (NFC) (#123892)
1 parent b7b9ccf commit d839c06

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lldb/source/Target/Process.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,17 +1294,12 @@ bool Process::HasAssignedIndexIDToThread(uint64_t thread_id) {
12941294
}
12951295

12961296
uint32_t Process::AssignIndexIDToThread(uint64_t thread_id) {
1297-
uint32_t result = 0;
1298-
std::map<uint64_t, uint32_t>::iterator iterator =
1299-
m_thread_id_to_index_id_map.find(thread_id);
1300-
if (iterator == m_thread_id_to_index_id_map.end()) {
1301-
result = ++m_thread_index_id;
1302-
m_thread_id_to_index_id_map[thread_id] = result;
1303-
} else {
1304-
result = iterator->second;
1305-
}
1297+
auto [iterator, inserted] =
1298+
m_thread_id_to_index_id_map.try_emplace(thread_id, m_thread_index_id + 1);
1299+
if (inserted)
1300+
++m_thread_index_id;
13061301

1307-
return result;
1302+
return iterator->second;
13081303
}
13091304

13101305
StateType Process::GetState() {

0 commit comments

Comments
 (0)