diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-08 23:33:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-08 23:33:52 +0000 |
commit | d43c7d2077743c1a88d48dacd0358080eabbaaac (patch) | |
tree | cd065af9eb0200b4d9c10c39179bf79dbf0548c8 | |
parent | a20021b20b26a421014d1d4994ed7223414b5561 (diff) |
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
-rw-r--r-- | lib/VMCore/Constants.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 5d7c35f232..de61c37d6e 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<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)); } |