[llvm-commits] [llvm] r48321 - /llvm/trunk/include/llvm/CodeGen/LiveVariables.h

Evan Cheng evan.cheng at apple.com
Wed Mar 12 19:42:55 PDT 2008


Author: evancheng
Date: Wed Mar 12 21:42:55 2008
New Revision: 48321

URL: http://llvm.org/viewvc/llvm-project?rev=48321&view=rev
Log:
Improve VarInfo::removeKill() by using std::find instead of linear search.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveVariables.h

Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=48321&r1=48320&r2=48321&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Wed Mar 12 21:42:55 2008
@@ -102,13 +102,12 @@
     /// machine instruction. Returns true if there was a kill
     /// corresponding to this instruction, false otherwise.
     bool removeKill(MachineInstr *MI) {
-      for (std::vector<MachineInstr*>::iterator i = Kills.begin(),
-             e = Kills.end(); i != e; ++i)
-        if (*i == MI) {
-          Kills.erase(i);
-          return true;
-        }
-      return false;
+      std::vector<MachineInstr*>::iterator
+        I = std::find(Kills.begin(), Kills.end(), MI);
+      if (I == Kills.end())
+        return false;
+      Kills.erase(I);
+      return true;
     }
     
     void dump() const;





More information about the llvm-commits mailing list