speed up iterative loop by using iterators. changes direction, but functionally equiv...
authorGabor Greif <ggreif@gmail.com>
Sat, 17 Jan 2009 00:14:25 +0000 (00:14 +0000)
committerGabor Greif <ggreif@gmail.com>
Sat, 17 Jan 2009 00:14:25 +0000 (00:14 +0000)
if this works out, I'll change the others next.

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

lib/Analysis/IPA/CallGraph.cpp

index c1082a002806b76792679579ffaa18c81a7fb6cd..b459246c298cbcae0232461408cb1c205a7289a4 100644 (file)
@@ -260,10 +260,10 @@ void CallGraphNode::dump() const { print(cerr); }
 /// specified call site.  Note that this method takes linear time, so it
 /// should be used sparingly.
 void CallGraphNode::removeCallEdgeFor(CallSite CS) {
-  for (unsigned i = CalledFunctions.size(); ; --i) {
-    assert(i && "Cannot find callsite to remove!");
-    if (CalledFunctions[i-1].first == CS) {
-      CalledFunctions.erase(CalledFunctions.begin()+i-1);
+  for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) {
+    assert(I != CalledFunctions.end() && "Cannot find callsite to remove!");
+    if (I->first == CS) {
+      CalledFunctions.erase(I);
       return;
     }
   }