Fix typo. Add more comment. Avoid extra hash_map search.
authorDevang Patel <dpatel@apple.com>
Mon, 23 Oct 2006 23:57:53 +0000 (23:57 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 23 Oct 2006 23:57:53 +0000 (23:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31144 91177308-0d34-0410-b5e6-96231b3b80d8

tools/lto/lto.cpp

index b9d76d67381a692cc8540153d6cdf6e76f3e4392..b00f76539b3ce99160464d7d8182aadc719667b4 100644 (file)
@@ -102,16 +102,18 @@ findExternalRefs(Value *value, std::set<std::string> &references,
       findExternalRefs(c->getOperand(i), references, mangler);
 }
 
-/// If Moduel with InputFilename is available then remove it.
+/// If Module with InputFilename is available then remove it from allModules
+/// and call delete on it.
 void
 LTO::removeModule (const std::string &InputFilename)
 {
   NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
-  if (pos != allModules.end()) {
-    Module *m = allModules[InputFilename.c_str()];
-    allModules.erase(pos);
-    delete m;
-  }
+  if (pos == allModules.end()) 
+    return;
+
+  Module *m = pos->second;
+  allModules.erase(pos);
+  delete m;
 }
 
 /// InputFilename is a LLVM bytecode file. If Module with InputFilename is