Eliminate a temporary std::vector in ConstantStruct::get().
authorJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 08:55:11 +0000 (08:55 +0000)
committerJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 08:55:11 +0000 (08:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133612 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 22d43a7d581a36d3b1a5768bc84a98570784dd1a..4c03288fe44073cdd78e7d85a14ef965a77ce3c0 100644 (file)
@@ -666,10 +666,8 @@ Constant *ConstantStruct::get(const StructType *ST, ArrayRef<Constant*> V) {
   
   // Create a ConstantAggregateZero value if all elements are zeros.
   for (unsigned i = 0, e = V.size(); i != e; ++i)
-    if (!V[i]->isNullValue()) {
-      // FIXME: Eliminate temporary std::vector here!
-      return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V.vec());
-    }
+    if (!V[i]->isNullValue())
+      return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
 
   return ConstantAggregateZero::get(ST);
 }