From: Benjamin Kramer Date: Wed, 5 Aug 2015 14:16:28 +0000 (+0000) Subject: [IR] Simplify code with ArrayRef::copy. No functionality change. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1678794d10e960ea2714729f85aaabd1380b7ac8;p=oota-llvm.git [IR] Simplify code with ArrayRef::copy. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244043 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index 2f6dbab7201..7f65e941f91 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -420,18 +420,14 @@ void StructType::setBody(ArrayRef Elements, bool isPacked) { 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(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) {