[llvm-commits] [llvm] r149952 - in /llvm/trunk/lib/VMCore: Constants.cpp Type.cpp
Bill Wendling
isanbard at gmail.com
Mon Feb 6 17:27:52 PST 2012
Author: void
Date: Mon Feb 6 19:27:51 2012
New Revision: 149952
URL: http://llvm.org/viewvc/llvm-project?rev=149952&view=rev
Log:
Reserve space in these vectors to prevent having to grow the array too
much. This gets us an addition 0.9% on 445.gobmk.
Modified:
llvm/trunk/lib/VMCore/Constants.cpp
llvm/trunk/lib/VMCore/Type.cpp
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=149952&r1=149951&r2=149952&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Feb 6 19:27:51 2012
@@ -784,9 +784,10 @@
StructType *ConstantStruct::getTypeForElements(LLVMContext &Context,
ArrayRef<Constant*> V,
bool Packed) {
- SmallVector<Type*, 16> EltTypes;
- for (unsigned i = 0, e = V.size(); i != e; ++i)
- EltTypes.push_back(V[i]->getType());
+ unsigned VecSize = V.size();
+ SmallVector<Type*, 16> EltTypes(VecSize);
+ for (unsigned i = 0; i != VecSize; ++i)
+ EltTypes[i] = V[i]->getType();
return StructType::get(Context, EltTypes, Packed);
}
Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=149952&r1=149951&r2=149952&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Mon Feb 6 19:27:51 2012
@@ -440,11 +440,12 @@
StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
bool isPacked) {
// FIXME: std::vector is horribly inefficient for this probe.
- std::vector<Type*> Key;
- for (unsigned i = 0, e = ETypes.size(); i != e; ++i) {
+ unsigned ETypesSize = ETypes.size();
+ std::vector<Type*> Key(ETypesSize);
+ for (unsigned i = 0, e = ETypesSize; i != e; ++i) {
assert(isValidElementType(ETypes[i]) &&
"Invalid type for structure element!");
- Key.push_back(ETypes[i]);
+ Key[i] = ETypes[i];
}
if (isPacked)
Key.push_back(0);
More information about the llvm-commits
mailing list