mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-01 12:24:24 +00:00
Preallocate vector, avoid unnecessary vector growth.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -526,6 +526,7 @@ Constant* ConstantArray::get(const ArrayType* T, Constant* const* Vals,
|
|||||||
Constant* ConstantArray::get(LLVMContext &Context, StringRef Str,
|
Constant* ConstantArray::get(LLVMContext &Context, StringRef Str,
|
||||||
bool AddNull) {
|
bool AddNull) {
|
||||||
std::vector<Constant*> ElementVals;
|
std::vector<Constant*> ElementVals;
|
||||||
|
ElementVals.reserve(Str.size() + size_t(AddNull));
|
||||||
for (unsigned i = 0; i < Str.size(); ++i)
|
for (unsigned i = 0; i < Str.size(); ++i)
|
||||||
ElementVals.push_back(ConstantInt::get(Type::getInt8Ty(Context), Str[i]));
|
ElementVals.push_back(ConstantInt::get(Type::getInt8Ty(Context), Str[i]));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user