From d306f68e6ba1971e22ddf5e9876114c1b897f5db Mon Sep 17 00:00:00 2001 From: Nick Hastings Date: Tue, 28 Mar 2023 23:04:42 -0400 Subject: [PATCH] Finished ResetDbgInfo/m_pElements removal on data structures --- public/tier1/utlblockmemory.h | 2 +- public/tier1/utlfixedmemory.h | 2 +- public/tier1/utllinkedlist.h | 8 -------- public/tier1/utlmultilist.h | 30 +----------------------------- public/tier1/utlntree.h | 14 -------------- public/tier1/utlrbtree.h | 18 ------------------ 6 files changed, 3 insertions(+), 71 deletions(-) diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index aff1fd50..bb34ecc4 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -52,7 +52,7 @@ public: // Set the size by which the memory grows - round up to the next power of 2 void Init( int nGrowSize = 0, int nInitSize = 0 ); - // here to match CUtlMemory, but only used by ResetDbgInfo, so it can just return NULL + // here to match CUtlMemory, but not used, so it can just return NULL T* Base() { return NULL; } const T* Base() const { return NULL; } diff --git a/public/tier1/utlfixedmemory.h b/public/tier1/utlfixedmemory.h index a2399ca8..b2ff2c67 100644 --- a/public/tier1/utlfixedmemory.h +++ b/public/tier1/utlfixedmemory.h @@ -51,7 +51,7 @@ public: // Set the size by which the memory grows void Init( int nGrowSize = 0, int nInitSize = 0 ); - // here to match CUtlMemory, but only used by ResetDbgInfo, so it can just return NULL + // here to match CUtlMemory, but not used, so it can just return NULL T* Base() { return NULL; } const T* Base() const { return NULL; } diff --git a/public/tier1/utllinkedlist.h b/public/tier1/utllinkedlist.h index fae0079e..6c0f308e 100644 --- a/public/tier1/utllinkedlist.h +++ b/public/tier1/utllinkedlist.h @@ -201,7 +201,6 @@ public: private: int MaxElementIndex() const { Assert( 0 ); return this->InvalidIndex(); } // fixedmemory containers don't support iteration from 0..maxelements-1 - void ResetDbgInfo() {} }; // this is kind of ugly, but until C++ gets templatized typedefs in C++0x, it's our only choice @@ -211,8 +210,6 @@ class CUtlBlockLinkedList : public CUtlLinkedList< T, I, true, I, CUtlBlockMemor public: CUtlBlockLinkedList( int growSize = 0, int initSize = 0 ) : CUtlLinkedList< T, I, true, I, CUtlBlockMemory< UtlLinkedListElem_t< T, I >, I > >( growSize, initSize ) {} -protected: - void ResetDbgInfo() {} }; @@ -227,7 +224,6 @@ CUtlLinkedList::CUtlLinkedList( int growSize, int initSize ) : // Prevent signed non-int datatypes COMPILE_TIME_ASSERT( sizeof(S) == 4 || ( ( (S)-1 ) > 0 ) ); ConstructList(); - ResetDbgInfo(); } template @@ -394,7 +390,6 @@ void CUtlLinkedList::EnsureCapacity( int num ) { MEM_ALLOC_CREDIT_CLASS(); m_Memory.EnsureCapacity(num); - ResetDbgInfo(); } template< class T, class S, bool ML, class I, class M > @@ -402,7 +397,6 @@ void CUtlLinkedList::SetGrowSize( int growSize ) { RemoveAll(); m_Memory.Init( growSize ); - ResetDbgInfo(); } @@ -422,7 +416,6 @@ void CUtlLinkedList::Purge() //Routing "m_LastAlloc = m_Memory.InvalidIterator();" through a local const to sidestep an internal compiler error on 360 builds const typename M::Iterator_t scInvalidIterator = m_Memory.InvalidIterator(); m_LastAlloc = scInvalidIterator; - ResetDbgInfo(); } @@ -461,7 +454,6 @@ I CUtlLinkedList::AllocInternal( bool multilist ) RESTRICT { MEM_ALLOC_CREDIT_CLASS(); m_Memory.Grow(); - ResetDbgInfo(); it = m_Memory.IsValidIterator( m_LastAlloc ) ? m_Memory.Next( m_LastAlloc ) : m_Memory.First(); diff --git a/public/tier1/utlmultilist.h b/public/tier1/utlmultilist.h index ead04886..aab4b7de 100644 --- a/public/tier1/utlmultilist.h +++ b/public/tier1/utlmultilist.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: Multiple linked list container class // @@ -145,30 +145,6 @@ protected: I m_FirstFree; I m_TotalElements; int m_MaxElementIndex; // The number allocated (use int so we can catch overflow) - - void ResetDbgInfo() - { - m_pElements = m_Memory.Base(); - -#ifdef _DEBUG - // Allocate space for the element list (which list is each element in) - if (m_Memory.NumAllocated() > 0) - { - if (!m_pElementList) - { - m_pElementList = (I*)malloc( m_Memory.NumAllocated() * sizeof(I) ); - } - else - { - m_pElementList = (I*)realloc( m_pElementList, m_Memory.NumAllocated() * sizeof(I) ); - } - } -#endif - } - - // For debugging purposes; - // it's in release builds so this can be used in libraries correctly - ListElem_t *m_pElements; }; @@ -204,7 +180,6 @@ void CUtlMultiList::ConstructList( ) m_FirstFree = InvalidIndex(); m_TotalElements = 0; m_MaxElementIndex = 0; - ResetDbgInfo(); } @@ -366,7 +341,6 @@ template< class T, class I > void CUtlMultiList::EnsureCapacity( int num ) { m_Memory.EnsureCapacity(num); - ResetDbgInfo(); } @@ -383,7 +357,6 @@ void CUtlMultiList::Purge() m_FirstFree = InvalidIndex(); m_TotalElements = 0; m_MaxElementIndex = 0; - ResetDbgInfo(); } @@ -409,7 +382,6 @@ I CUtlMultiList::Alloc( ) if (m_MaxElementIndex == m_Memory.NumAllocated()) { m_Memory.Grow(); - ResetDbgInfo(); if ( m_MaxElementIndex >= m_Memory.NumAllocated() ) { diff --git a/public/tier1/utlntree.h b/public/tier1/utlntree.h index aae89dcb..25b25423 100644 --- a/public/tier1/utlntree.h +++ b/public/tier1/utlntree.h @@ -117,11 +117,6 @@ protected: // Gets at the node element.... Node_t& InternalNode( I i ) { return m_Memory[i]; } const Node_t& InternalNode( I i ) const { return m_Memory[i]; } - - void ResetDbgInfo() - { - m_pElements = m_Memory.Base(); - } // copy constructors not allowed CUtlNTree( CUtlNTree const& tree ) { Assert(0); } @@ -131,10 +126,6 @@ protected: I m_FirstFree; I m_ElementCount; // The number actually in the tree I m_MaxElementIndex; // The max index we've ever assigned - - // For debugging purposes; - // it's in release builds so this can be used in libraries correctly - Node_t *m_pElements; }; @@ -147,7 +138,6 @@ CUtlNTree::CUtlNTree( int growSize, int initSize ) : m_Memory(growSize, initSize) { ConstructList(); - ResetDbgInfo(); } template @@ -155,7 +145,6 @@ CUtlNTree::CUtlNTree( void* pMemory, int memsize ) : m_Memory(pMemory, memsize/sizeof(T)) { ConstructList(); - ResetDbgInfo(); } template @@ -279,7 +268,6 @@ void CUtlNTree::EnsureCapacity( int num ) { MEM_ALLOC_CREDIT_CLASS(); m_Memory.EnsureCapacity(num); - ResetDbgInfo(); } @@ -293,7 +281,6 @@ void CUtlNTree::Purge() m_Memory.Purge( ); m_FirstFree = InvalidIndex(); m_MaxElementIndex = 0; - ResetDbgInfo(); } @@ -333,7 +320,6 @@ I CUtlNTree::AllocInternal( ) Node_t &node = InternalNode( elem ); node.m_NextSibling = node.m_PrevSibling = node.m_Parent = node.m_FirstChild = INVALID_NTREE_IDX; - ResetDbgInfo(); // one more element baby ++m_ElementCount; diff --git a/public/tier1/utlrbtree.h b/public/tier1/utlrbtree.h index 5b55004b..093eb980 100644 --- a/public/tier1/utlrbtree.h +++ b/public/tier1/utlrbtree.h @@ -287,18 +287,10 @@ protected: I m_FirstFree; typename M::Iterator_t m_LastAlloc; // the last index allocated - Node_t* m_pElements; - FORCEINLINE M const &Elements( void ) const { return m_Elements; } - - - void ResetDbgInfo() - { - m_pElements = (Node_t*)m_Elements.Base(); - } }; // this is kind of ugly, but until C++ gets templatized typedefs in C++0x, it's our only choice @@ -331,9 +323,6 @@ public: return LeftChild(i) != i; } -protected: - void ResetDbgInfo() {} - private: // this doesn't make sense for fixed rbtrees, since there's no useful max pointer, and the index space isn't contiguous anyways I MaxElement() const; @@ -349,8 +338,6 @@ public: : CUtlRBTree< T, I, L, CUtlBlockMemory< UtlRBTreeNode_t< T, I >, I > >( growSize, initSize, lessfunc ) {} CUtlBlockRBTree( const LessFunc_t &lessfunc ) : CUtlRBTree< T, I, L, CUtlBlockMemory< UtlRBTreeNode_t< T, I >, I > >( lessfunc ) {} -protected: - void ResetDbgInfo() {} }; @@ -367,7 +354,6 @@ m_NumElements( 0 ), m_FirstFree( InvalidIndex() ), m_LastAlloc( m_Elements.InvalidIterator() ) { - ResetDbgInfo(); } template < class T, class I, typename L, class M > @@ -379,7 +365,6 @@ m_NumElements( 0 ), m_FirstFree( InvalidIndex() ), m_LastAlloc( m_Elements.InvalidIterator() ) { - ResetDbgInfo(); } template < class T, class I, typename L, class M > @@ -405,7 +390,6 @@ inline void CUtlRBTree::CopyFrom( const CUtlRBTree &othe m_NumElements = other.m_NumElements; m_FirstFree = other.m_FirstFree; m_LastAlloc = other.m_LastAlloc; - ResetDbgInfo(); } //----------------------------------------------------------------------------- @@ -692,7 +676,6 @@ I CUtlRBTree::NewNode() #endif Construct( &Element( elem ) ); - ResetDbgInfo(); return elem; } @@ -1562,7 +1545,6 @@ void CUtlRBTree::Swap( CUtlRBTree< T, I, L > &that ) V_swap( m_Root, that.m_Root ); V_swap( m_NumElements, that.m_NumElements ); V_swap( m_FirstFree, that.m_FirstFree ); - V_swap( m_pElements, that.m_pElements ); V_swap( m_LastAlloc, that.m_LastAlloc ); Assert( IsValid() ); Assert( m_Elements.IsValidIterator( m_LastAlloc ) || ( m_NumElements == 0 && m_FirstFree == InvalidIndex() ) );