Skip to content

Commit ca9f396

Browse files
[lldb] Avoid repeated hash lookups (NFC) (#113024)
1 parent 8819267 commit ca9f396

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lldb/source/Core/DataFileCache.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,12 @@ bool CacheSignature::Decode(const lldb_private::DataExtractor &data,
264264
}
265265

266266
uint32_t ConstStringTable::Add(ConstString s) {
267-
auto pos = m_string_to_offset.find(s);
268-
if (pos != m_string_to_offset.end())
269-
return pos->second;
270-
const uint32_t offset = m_next_offset;
271-
m_strings.push_back(s);
272-
m_string_to_offset[s] = offset;
273-
m_next_offset += s.GetLength() + 1;
274-
return offset;
267+
auto [pos, inserted] = m_string_to_offset.try_emplace(s, m_next_offset);
268+
if (inserted) {
269+
m_strings.push_back(s);
270+
m_next_offset += s.GetLength() + 1;
271+
}
272+
return pos->second;
275273
}
276274

277275
static const llvm::StringRef kStringTableIdentifier("STAB");

0 commit comments

Comments
 (0)