[llvm-commits] [llvm] r62385 - /llvm/trunk/lib/Analysis/IPA/CallGraph.cpp

Gabor Greif ggreif at gmail.com
Fri Jan 16 16:14:25 PST 2009


Author: ggreif
Date: Fri Jan 16 18:14:25 2009
New Revision: 62385

URL: http://llvm.org/viewvc/llvm-project?rev=62385&view=rev
Log:
speed up iterative loop by using iterators. changes direction, but functionally equivalent
if this works out, I'll change the others next.

Modified:
    llvm/trunk/lib/Analysis/IPA/CallGraph.cpp

Modified: llvm/trunk/lib/Analysis/IPA/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraph.cpp?rev=62385&r1=62384&r2=62385&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Fri Jan 16 18:14:25 2009
@@ -260,10 +260,10 @@
 /// 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;
     }
   }





More information about the llvm-commits mailing list