From: Chris Lattner Date: Tue, 8 Oct 2002 23:33:52 +0000 (+0000) Subject: Fix bug: Assembler/2002-10-08-LargeArrayPerformance.ll by using X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d43c7d2077743c1a88d48dacd0358080eabbaaac;p=oota-llvm.git 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 --- diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 5d7c35f232d..de61c37d6e3 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -191,7 +191,8 @@ ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) { ConstantArray::ConstantArray(const ArrayType *T, const std::vector &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)); }