[llvm-commits] [llvm] r140260 - /llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 21 10:31:42 PDT 2011


Author: d0k
Date: Wed Sep 21 12:31:42 2011
New Revision: 140260

URL: http://llvm.org/viewvc/llvm-project?rev=140260&view=rev
Log:
DWARF: avoid unnecessary map lookups.

Modified:
    llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp?rev=140260&r1=140259&r2=140260&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp Wed Sep 21 12:31:42 2011
@@ -116,17 +116,16 @@
 const DWARFDebugLine::LineTable *
 DWARFDebugLine::getOrParseLineTable(DataExtractor debug_line_data,
                                     uint32_t offset) {
-  LineTableIter pos = LineTableMap.find(offset);
-  if (pos == LineTableMap.end()) {
+  std::pair<LineTableIter, bool> pos =
+    LineTableMap.insert(LineTableMapTy::value_type(offset, LineTable()));
+  if (pos.second) {
     // Parse and cache the line table for at this offset.
     State state;
     if (!parseStatementTable(debug_line_data, &offset, state))
       return 0;
-    // FIXME: double lookup.
-    LineTableMap[offset] = state;
-    return &LineTableMap[offset];
+    pos.first->second = state;
   }
-  return &pos->second;
+  return &pos.first->second;
 }
 
 bool





More information about the llvm-commits mailing list