[llvm-commits] CVS: llvm/lib/Analysis/IPA/FindUsedTypes.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri May 28 00:40:02 PDT 2004


Changes in directory llvm/lib/Analysis/IPA:

FindUsedTypes.cpp updated: 1.26 -> 1.27

---
Log message:

Minor efficiency gain: do 1 nlogn lookup instead of two
Code cleanup


---
Diffs of the changes:  (+4 -7)

Index: llvm/lib/Analysis/IPA/FindUsedTypes.cpp
diff -u llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.26 llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.27
--- llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.26	Sun May  9 01:22:29 2004
+++ llvm/lib/Analysis/IPA/FindUsedTypes.cpp	Fri May 28 00:36:49 2004
@@ -32,12 +32,10 @@
 // collection of used types.
 //
 void FindUsedTypes::IncorporateType(const Type *Ty) {
-  if (UsedTypes.count(Ty)) return;  // Already contain Ty.
+  // If ty doesn't already exist in the used types map, add it now, otherwise 
+  // return.
+  if (!UsedTypes.insert(Ty).second) return;  // Already contain Ty.
                              
-  // If ty doesn't already exist in the used types map, add it now.
-  //
-  UsedTypes.insert(Ty);
-  
   // Make sure to add any types this type references now.
   //
   for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
@@ -79,9 +77,8 @@
     for (const_inst_iterator II = inst_begin(F), IE = inst_end(F);
          II != IE; ++II) {
       const Instruction &I = *II;
-      const Type *Ty = I.getType();
     
-      IncorporateType(Ty);  // Incorporate the type of the instruction
+      IncorporateType(I.getType());  // Incorporate the type of the instruction
       for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
            OI != OE; ++OI)
         IncorporateValue(*OI);  // Insert inst operand types as well





More information about the llvm-commits mailing list