Author: Kazu Hirata Date: 2024-10-19T14:39:25-07:00 New Revision: ca9f396cac0371a398eeef73182987a55a21e4a1
URL: https://github.com/llvm/llvm-project/commit/ca9f396cac0371a398eeef73182987a55a21e4a1 DIFF: https://github.com/llvm/llvm-project/commit/ca9f396cac0371a398eeef73182987a55a21e4a1.diff LOG: [lldb] Avoid repeated hash lookups (NFC) (#113024) Added: Modified: lldb/source/Core/DataFileCache.cpp Removed: ################################################################################ diff --git a/lldb/source/Core/DataFileCache.cpp b/lldb/source/Core/DataFileCache.cpp index a8127efc1df064..ef0e07a8b03420 100644 --- a/lldb/source/Core/DataFileCache.cpp +++ b/lldb/source/Core/DataFileCache.cpp @@ -264,14 +264,12 @@ bool CacheSignature::Decode(const lldb_private::DataExtractor &data, } uint32_t ConstStringTable::Add(ConstString s) { - auto pos = m_string_to_offset.find(s); - if (pos != m_string_to_offset.end()) - return pos->second; - const uint32_t offset = m_next_offset; - m_strings.push_back(s); - m_string_to_offset[s] = offset; - m_next_offset += s.GetLength() + 1; - return offset; + auto [pos, inserted] = m_string_to_offset.try_emplace(s, m_next_offset); + if (inserted) { + m_strings.push_back(s); + m_next_offset += s.GetLength() + 1; + } + return pos->second; } static const llvm::StringRef kStringTableIdentifier("STAB"); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits