[lld] r241385 - Use map::insert instead of checking existence of a key and insert. NFC.

Rui Ueyama ruiu at google.com
Fri Jul 3 19:00:22 PDT 2015


Author: ruiu
Date: Fri Jul  3 21:00:22 2015
New Revision: 241385

URL: http://llvm.org/viewvc/llvm-project?rev=241385&view=rev
Log:
Use map::insert instead of checking existence of a key and insert. NFC.

Modified:
    lld/trunk/COFF/DriverUtils.cpp

Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=241385&r1=241384&r2=241385&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Fri Jul  3 21:00:22 2015
@@ -399,13 +399,14 @@ std::error_code fixupExports() {
   std::map<StringRef, Export *> Map;
   std::vector<Export> V;
   for (Export &E : Config->Exports) {
-    auto It = Map.find(E.Name);
-    if (It == Map.end()) {
-      Map.insert(It, std::make_pair(E.Name, &E));
+    auto Pair = Map.insert(std::make_pair(E.Name, &E));
+    bool Inserted = Pair.second;
+    if (Inserted) {
       V.push_back(E);
       continue;
     }
-    if (E == *It->second)
+    Export *Existing = Pair.first->second;
+    if (E == *Existing)
       continue;
     llvm::errs() << "warning: duplicate /export option: " << E.Name << "\n";
     continue;





More information about the llvm-commits mailing list