[llvm-commits] [llvm] r109971 - /llvm/trunk/lib/VMCore/Constants.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sun Aug 1 04:43:26 PDT 2010
Author: d0k
Date: Sun Aug 1 06:43:26 2010
New Revision: 109971
URL: http://llvm.org/viewvc/llvm-project?rev=109971&view=rev
Log:
Preallocate vector, avoid unnecessary vector growth.
Modified:
llvm/trunk/lib/VMCore/Constants.cpp
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=109971&r1=109970&r2=109971&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Sun Aug 1 06:43:26 2010
@@ -526,6 +526,7 @@
Constant* ConstantArray::get(LLVMContext &Context, StringRef Str,
bool AddNull) {
std::vector<Constant*> ElementVals;
+ ElementVals.reserve(Str.size() + size_t(AddNull));
for (unsigned i = 0; i < Str.size(); ++i)
ElementVals.push_back(ConstantInt::get(Type::getInt8Ty(Context), Str[i]));
More information about the llvm-commits
mailing list