Cache element types in StructType.

Previously, GetElementType() would end up causing dynamic allocation to
happen to compute the final element type (turning types with unbound
variability into the same type with the struct's variability) each it was
called, which was wasteful and slow.  Now we cache the result.

Another 20% perf on compiling that problematic program.
This commit is contained in:
Matt Pharr
2012-05-04 12:07:01 -07:00
parent 2791bd0015
commit 78d62705cc
2 changed files with 19 additions and 10 deletions

2
type.h
View File

@@ -716,6 +716,8 @@ private:
const bool isConst;
const SourcePos pos;
mutable std::vector<const Type *> finalElementTypes;
mutable const StructType *oppositeConstStructType;
};