DWARF: avoid unnecessary map lookups.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 21 Sep 2011 17:31:42 +0000 (17:31 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 21 Sep 2011 17:31:42 +0000 (17:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140260 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARFDebugLine.cpp

index d8200a0fd6be1ba4804f8cec955a6f773faaca1f..c91281cac8aaf3c204bd2ac8a2771200ddfff7ee 100644 (file)
@@ -116,17 +116,16 @@ DWARFDebugLine::getLineTable(uint32_t offset) const {
 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