[llvm] r244043 - [IR] Simplify code with ArrayRef::copy. No functionality change.

Benjamin Kramer benny.kra at googlemail.com
Wed Aug 5 07:16:28 PDT 2015


Author: d0k
Date: Wed Aug  5 09:16:28 2015
New Revision: 244043

URL: http://llvm.org/viewvc/llvm-project?rev=244043&view=rev
Log:
[IR] Simplify code with ArrayRef::copy. No functionality change.

Modified:
    llvm/trunk/lib/IR/Type.cpp

Modified: llvm/trunk/lib/IR/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=244043&r1=244042&r2=244043&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Type.cpp (original)
+++ llvm/trunk/lib/IR/Type.cpp Wed Aug  5 09:16:28 2015
@@ -420,18 +420,14 @@ void StructType::setBody(ArrayRef<Type*>
   if (isPacked)
     setSubclassData(getSubclassData() | SCDB_Packed);
 
+  NumContainedTys = Elements.size();
+
   if (Elements.empty()) {
     ContainedTys = nullptr;
-    NumContainedTys = 0;
     return;
   }
 
-  unsigned NumElements = Elements.size();
-  Type **Elts = getContext().pImpl->TypeAllocator.Allocate<Type*>(NumElements);
-  memcpy(Elts, Elements.data(), sizeof(Elements[0]) * NumElements);
-  
-  ContainedTys = Elts;
-  NumContainedTys = NumElements;
+  ContainedTys = Elements.copy(getContext().pImpl->TypeAllocator).data();
 }
 
 void StructType::setName(StringRef Name) {




More information about the llvm-commits mailing list