]> granicus.if.org Git - clang/commitdiff
Improved efficiency by using iterator returned by erase, rather then restarting.
authorChad Rosier <mcrosier@apple.com>
Mon, 8 Aug 2011 17:17:15 +0000 (17:17 +0000)
committerChad Rosier <mcrosier@apple.com>
Mon, 8 Aug 2011 17:17:15 +0000 (17:17 +0000)
Thanks to David Blaikie for pointing this out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137051 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ArgList.cpp

index e5341884eecfb3eef9ae1c5ff63da560f557da1d..0d7b057c78cf973febbedc368a4643c1579ca85a 100644 (file)
@@ -47,11 +47,11 @@ void ArgList::append(Arg *A) {
 }
 
 void ArgList::eraseArg(OptSpecifier Id) {
-  for (iterator it = begin(), ie = end(); it != ie; ++it) {
+  for (iterator it = begin(), ie = end(); it != ie; ) {
     if ((*it)->getOption().matches(Id)) {
-      Args.erase(it);
-      it = begin();
-      ie = end();
+      it = Args.erase(it);
+    } else {
+      ++it;
     }
   }
 }