[Lldb-commits] [lldb] 8673d0e - [lldb] Avoid repeated map lookups (NFC) (#113073)

via lldb-commits lldb-commits at lists.llvm.org
Sun Oct 20 09:07:13 PDT 2024


Author: Kazu Hirata
Date: 2024-10-20T09:07:10-07:00
New Revision: 8673d0e0673dd1a5e6f7a5df7509c45e33582987

URL: https://github.com/llvm/llvm-project/commit/8673d0e0673dd1a5e6f7a5df7509c45e33582987
DIFF: https://github.com/llvm/llvm-project/commit/8673d0e0673dd1a5e6f7a5df7509c45e33582987.diff

LOG: [lldb] Avoid repeated map lookups (NFC) (#113073)

Added: 
    

Modified: 
    lldb/source/Interpreter/Options.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 6a90b2cc9b9896..893a3b71604ba8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -251,12 +251,9 @@ Option *Options::GetLongOptions() {
       m_getopt_table[i].flag = nullptr;
       m_getopt_table[i].val = short_opt;
 
-      if (option_seen.find(short_opt) == option_seen.end()) {
-        option_seen[short_opt] = i;
-      } else if (short_opt) {
+      auto [pos, inserted] = option_seen.try_emplace(short_opt, i);
+      if (!inserted && short_opt) {
         m_getopt_table[i].val = 0;
-        std::map<int, uint32_t>::const_iterator pos =
-            option_seen.find(short_opt);
         StreamString strm;
         if (defs[i].HasShortOption())
           Debugger::ReportError(


        


More information about the lldb-commits mailing list