From 074d7b446aa1bf5d979d9c03b0f278208ca53a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Krupi=C5=84ski?= Date: Wed, 15 Sep 2021 21:10:40 +0200 Subject: [PATCH 1/2] Do not define empty non-virtual destructors --- src/D3D12MemAlloc.cpp | 18 ------------------ src/D3D12MemAlloc.h | 1 - 2 files changed, 19 deletions(-) diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp index b6efe6b..5020e00 100644 --- a/src/D3D12MemAlloc.cpp +++ b/src/D3D12MemAlloc.cpp @@ -1553,7 +1553,6 @@ public: // allocationCallbacks externally owned, must outlive this object. List(const ALLOCATION_CALLBACKS& allocationCallbacks); - ~List(); void Clear(); size_t GetCount() const { return m_Count; } @@ -1776,13 +1775,6 @@ List::List(const ALLOCATION_CALLBACKS& allocationCallbacks) : { } -template -List::~List() -{ - // Intentionally not calling Clear, because that would be unnecessary - // computations to return all items to m_ItemAllocator as free. -} - template void List::Clear() { @@ -6002,11 +5994,6 @@ Allocation::Allocation(AllocatorPimpl* allocator, UINT64 size, BOOL wasZeroIniti m_PackedData.SetWasZeroInitialized(wasZeroInitialized); } -Allocation::~Allocation() -{ - // Nothing here, everything already done in Release. -} - void Allocation::InitCommitted(CommittedAllocationList* list) { m_PackedData.SetType(TYPE_COMMITTED); @@ -6311,7 +6298,6 @@ public: BlockMetadata_Generic m_Metadata; VirtualBlockPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks, UINT64 size); - ~VirtualBlockPimpl(); }; VirtualBlockPimpl::VirtualBlockPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks, UINT64 size) : @@ -6323,10 +6309,6 @@ VirtualBlockPimpl::VirtualBlockPimpl(const ALLOCATION_CALLBACKS& allocationCallb m_Metadata.Init(m_Size); } -VirtualBlockPimpl::~VirtualBlockPimpl() -{ -} - //////////////////////////////////////////////////////////////////////////////// // Public class VirtualBlock implementation diff --git a/src/D3D12MemAlloc.h b/src/D3D12MemAlloc.h index 8fc4d49..b326271 100644 --- a/src/D3D12MemAlloc.h +++ b/src/D3D12MemAlloc.h @@ -401,7 +401,6 @@ private: } m_PackedData; Allocation(AllocatorPimpl* allocator, UINT64 size, BOOL wasZeroInitialized); - ~Allocation(); void InitCommitted(CommittedAllocationList* list); void InitPlaced(UINT64 offset, UINT64 alignment, NormalBlock* block); void InitHeap(CommittedAllocationList* list, ID3D12Heap* heap); From 48521a1f8eb2110d7f341ea01b37cd701cde003f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Krupi=C5=84ski?= Date: Thu, 16 Sep 2021 19:21:19 +0200 Subject: [PATCH 2/2] Preserve comments explaining empty destructors --- src/D3D12MemAlloc.cpp | 5 +++++ src/D3D12MemAlloc.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp index 5020e00..15a91f6 100644 --- a/src/D3D12MemAlloc.cpp +++ b/src/D3D12MemAlloc.cpp @@ -1553,6 +1553,11 @@ public: // allocationCallbacks externally owned, must outlive this object. List(const ALLOCATION_CALLBACKS& allocationCallbacks); + + // Intentionally not calling Clear, because that would be unnecessary + // computations to return all items to m_ItemAllocator as free. + // ~List() {} + void Clear(); size_t GetCount() const { return m_Count; } diff --git a/src/D3D12MemAlloc.h b/src/D3D12MemAlloc.h index b326271..61a49b8 100644 --- a/src/D3D12MemAlloc.h +++ b/src/D3D12MemAlloc.h @@ -401,6 +401,9 @@ private: } m_PackedData; Allocation(AllocatorPimpl* allocator, UINT64 size, BOOL wasZeroInitialized); + // Nothing here, everything already done in Release. + // ~Allocation() {} + void InitCommitted(CommittedAllocationList* list); void InitPlaced(UINT64 offset, UINT64 alignment, NormalBlock* block); void InitHeap(CommittedAllocationList* list, ID3D12Heap* heap);