summaryrefslogtreecommitdiff
path: root/lib/Analysis/IPA/FindUsedTypes.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-28 05:36:49 +0000
committerChris Lattner <sabre@nondot.org>2004-05-28 05:36:49 +0000
commita5dcc4f7b2a65afbeec9008733f47e6beee24bde (patch)
treedcce17e70ea5d8df74087361e03345d6d714c7d6 /lib/Analysis/IPA/FindUsedTypes.cpp
parentd06a5493841d5c49dccdd97be5dd93762dc345f1 (diff)
downloadllvm-a5dcc4f7b2a65afbeec9008733f47e6beee24bde.tar.gz
llvm-a5dcc4f7b2a65afbeec9008733f47e6beee24bde.tar.bz2
llvm-a5dcc4f7b2a65afbeec9008733f47e6beee24bde.tar.xz
Minor efficiency gain: do 1 nlogn lookup instead of two
Code cleanup git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/FindUsedTypes.cpp')
-rw-r--r--lib/Analysis/IPA/FindUsedTypes.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp
index 15208f60db..c50e3ecaaa 100644
--- a/lib/Analysis/IPA/FindUsedTypes.cpp
+++ b/lib/Analysis/IPA/FindUsedTypes.cpp
@@ -32,12 +32,10 @@ void FindUsedTypes::stub() {}
// 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 @@ bool FindUsedTypes::run(Module &m) {
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