Fix bug: Assembler/2002-10-08-LargeArrayPerformance.ll by using

std::vector::reserve when possible


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4085 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-10-08 23:33:52 +00:00
parent a20021b20b
commit d43c7d2077

View File

@ -191,7 +191,8 @@ ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) {
ConstantArray::ConstantArray(const ArrayType *T,
const std::vector<Constant*> &V) : Constant(T) {
for (unsigned i = 0; i < V.size(); i++) {
Operands.reserve(V.size());
for (unsigned i = 0, e = V.size(); i != e; ++i) {
assert(V[i]->getType() == T->getElementType());
Operands.push_back(Use(V[i], this));
}
@ -202,7 +203,8 @@ ConstantStruct::ConstantStruct(const StructType *T,
const StructType::ElementTypes &ETypes = T->getElementTypes();
assert(V.size() == ETypes.size() &&
"Invalid initializer vector for constant structure");
for (unsigned i = 0; i < V.size(); i++) {
Operands.reserve(V.size());
for (unsigned i = 0, e = V.size(); i != e; ++i) {
assert(V[i]->getType() == ETypes[i]);
Operands.push_back(Use(V[i], this));
}