aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-02-07 00:13:27 +0000
committerBill Wendling <isanbard@gmail.com>2012-02-07 00:13:27 +0000
commitf9ea953f22d8e50cae7fd541406d6f563ef86cda (patch)
tree7e1c7bd72ef60d5ebe806ee9ed6b1ec00404da65 /lib/CodeGen/CGExprConstant.cpp
parent35f18a5e8b5a434894a4886ed98f3dbaa3b895c0 (diff)
Use a more efficient container for these values. Also reserve space when using a
std::vector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149936 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--lib/CodeGen/CGExprConstant.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index ee0d9a4a81..c68225b5ec 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -590,8 +590,8 @@ public:
// Build a struct with the union sub-element as the first member,
// and padded to the appropriate size
- std::vector<llvm::Constant*> Elts;
- std::vector<llvm::Type*> Types;
+ SmallVector<llvm::Constant*, 2> Elts;
+ SmallVector<llvm::Type*, 2> Types;
Elts.push_back(C);
Types.push_back(C->getType());
unsigned CurSize = CGM.getTargetData().getTypeAllocSize(C->getType());
@@ -689,7 +689,6 @@ public:
isa<ObjCEncodeExpr>(ILE->getInit(0))))
return Visit(ILE->getInit(0));
- std::vector<llvm::Constant*> Elts;
llvm::ArrayType *AType =
cast<llvm::ArrayType>(ConvertType(ILE->getType()));
llvm::Type *ElemTy = AType->getElementType();
@@ -700,6 +699,8 @@ public:
unsigned NumInitableElts = std::min(NumInitElements, NumElements);
// Copy initializer elements.
+ std::vector<llvm::Constant*> Elts;
+ Elts.reserve(NumInitableElts + NumElements);
unsigned i = 0;
bool RewriteType = false;
for (; i < NumInitableElts; ++i) {
@@ -727,6 +728,7 @@ public:
if (RewriteType) {
// FIXME: Try to avoid packing the array
std::vector<llvm::Type*> Types;
+ Types.reserve(NumInitableElts + NumElements);
for (unsigned i = 0, e = Elts.size(); i < e; ++i)
Types.push_back(Elts[i]->getType());
llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
@@ -1132,6 +1134,7 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value,
if (!CommonElementType) {
// FIXME: Try to avoid packing the array
std::vector<llvm::Type*> Types;
+ Types.reserve(NumElements);
for (unsigned i = 0, e = Elts.size(); i < e; ++i)
Types.push_back(Elts[i]->getType());
llvm::StructType *SType = llvm::StructType::get(VMContext, Types, true);