Skip to content

Commit 3d4af4e

Browse files
committed
Preallocate vector, avoid unnecessary vector growth.
llvm-svn: 109971
1 parent 6602bb1 commit 3d4af4e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/VMCore/Constants.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ Constant* ConstantArray::get(const ArrayType* T, Constant* const* Vals,
526526
Constant* ConstantArray::get(LLVMContext &Context, StringRef Str,
527527
bool AddNull) {
528528
std::vector<Constant*> ElementVals;
529+
ElementVals.reserve(Str.size() + size_t(AddNull));
529530
for (unsigned i = 0; i < Str.size(); ++i)
530531
ElementVals.push_back(ConstantInt::get(Type::getInt8Ty(Context), Str[i]));
531532

0 commit comments

Comments
 (0)