diff options
author | Chris Lattner <sabre@nondot.org> | 2003-01-14 19:42:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-01-14 19:42:39 +0000 |
commit | 6a490cedb5c07be90812dfa57a5346c2ddf5d415 (patch) | |
tree | 4e700d47070d0b982e58481c74354846cac2bda4 /lib/VMCore | |
parent | 408e72df5067408acdab897f03c9d665089f9971 (diff) | |
download | external_llvm-6a490cedb5c07be90812dfa57a5346c2ddf5d415.zip external_llvm-6a490cedb5c07be90812dfa57a5346c2ddf5d415.tar.gz external_llvm-6a490cedb5c07be90812dfa57a5346c2ddf5d415.tar.bz2 |
Make type resolution a bit more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Type.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 4990700..398937a 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -259,13 +259,12 @@ OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { // static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, bool &isAbstract, bool &isRecursive) { - string Result; if (!Ty->isAbstract() && !Ty->isRecursive() && // Base case for the recursion Ty->getDescription().size()) { - Result = Ty->getDescription(); // Primitive = leaf type + return Ty->getDescription(); // Primitive = leaf type } else if (isa<OpaqueType>(Ty)) { // Base case for the recursion - Result = Ty->getDescription(); // Opaque = leaf type isAbstract = true; // This whole type is abstract! + return Ty->getDescription(); // Opaque = leaf type } else { // Check to see if the Type is already on the stack... unsigned Slot = 0, CurSize = TypeStack.size(); @@ -276,9 +275,10 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, // Generate the appropriate upreference to handle this. // if (Slot < CurSize) { - Result = "\\" + utostr(CurSize-Slot); // Here's the upreference isRecursive = true; // We know we are recursive + return "\\" + utostr(CurSize-Slot); // Here's the upreference } else { // Recursive case: abstract derived type... + string Result; TypeStack.push_back(Ty); // Add us to the stack.. switch (Ty->getPrimitiveID()) { @@ -334,9 +334,9 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, } TypeStack.pop_back(); // Remove self from stack... + return Result; } } - return Result; } @@ -1043,7 +1043,7 @@ void StructType::refineAbstractType(const DerivedType *OldType, << OldType->getDescription() << "], " << (void*)NewType << " [" << NewType->getDescription() << "])\n"; #endif - for (unsigned i = 0, e = ETypes.size(); i != e; ++i) + for (int i = ETypes.size()-1; i >= 0; --i) if (ETypes[i] == OldType) { ETypes[i].removeUserFromConcrete(); |