mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Make getContainedType more efficient by not returning null if out of range!
llvm-svn: 8987
This commit is contained in:
parent
01d8fd6a3b
commit
8e6b42c567
@ -156,8 +156,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
virtual const Type *getContainedType(unsigned i) const {
|
virtual const Type *getContainedType(unsigned i) const {
|
||||||
return i == 0 ? ResultType :
|
return i == 0 ? ResultType.get() : ParamTys[i-1].get();
|
||||||
(i <= ParamTys.size() ? ParamTys[i-1].get() : 0);
|
|
||||||
}
|
}
|
||||||
virtual unsigned getNumContainedTypes() const { return ParamTys.size()+1; }
|
virtual unsigned getNumContainedTypes() const { return ParamTys.size()+1; }
|
||||||
|
|
||||||
@ -239,7 +238,7 @@ public:
|
|||||||
inline const ElementTypes &getElementTypes() const { return ETypes; }
|
inline const ElementTypes &getElementTypes() const { return ETypes; }
|
||||||
|
|
||||||
virtual const Type *getContainedType(unsigned i) const {
|
virtual const Type *getContainedType(unsigned i) const {
|
||||||
return i < ETypes.size() ? ETypes[i].get() : 0;
|
return ETypes[i].get();
|
||||||
}
|
}
|
||||||
virtual unsigned getNumContainedTypes() const { return ETypes.size(); }
|
virtual unsigned getNumContainedTypes() const { return ETypes.size(); }
|
||||||
|
|
||||||
@ -289,7 +288,7 @@ public:
|
|||||||
inline const Type *getElementType() const { return ElementType; }
|
inline const Type *getElementType() const { return ElementType; }
|
||||||
|
|
||||||
virtual const Type *getContainedType(unsigned i) const {
|
virtual const Type *getContainedType(unsigned i) const {
|
||||||
return i == 0 ? ElementType.get() : 0;
|
return ElementType.get();
|
||||||
}
|
}
|
||||||
virtual unsigned getNumContainedTypes() const { return 1; }
|
virtual unsigned getNumContainedTypes() const { return 1; }
|
||||||
|
|
||||||
|
@ -202,11 +202,11 @@ public:
|
|||||||
|
|
||||||
/// getContainedType - This method is used to implement the type iterator
|
/// getContainedType - This method is used to implement the type iterator
|
||||||
/// (defined a the end of the file). For derived types, this returns the
|
/// (defined a the end of the file). For derived types, this returns the
|
||||||
/// types 'contained' in the derived type, returning 0 when 'i' becomes
|
/// types 'contained' in the derived type.
|
||||||
/// invalid. This allows the user to iterate over the types in a struct, for
|
|
||||||
/// example, really easily.
|
|
||||||
///
|
///
|
||||||
virtual const Type *getContainedType(unsigned i) const { return 0; }
|
virtual const Type *getContainedType(unsigned i) const {
|
||||||
|
assert(0 && "No contained types!");
|
||||||
|
}
|
||||||
|
|
||||||
/// getNumContainedTypes - Return the number of types in the derived type
|
/// getNumContainedTypes - Return the number of types in the derived type
|
||||||
virtual unsigned getNumContainedTypes() const { return 0; }
|
virtual unsigned getNumContainedTypes() const { return 0; }
|
||||||
|
Loading…
Reference in New Issue
Block a user