diff --git a/r5dev/public/tier1/utlstringmap.h b/r5dev/public/tier1/utlstringmap.h index 82c2e975..7bc46b16 100644 --- a/r5dev/public/tier1/utlstringmap.h +++ b/r5dev/public/tier1/utlstringmap.h @@ -96,7 +96,7 @@ public: else // ( m_Vector.Count() < index ) { // this is a strange shouldn't-happen case. - AssertMsg( false, "CUtlStringMap insert unexpected entries." ); + //AssertMsg( false, "CUtlStringMap insert unexpected entries." ); m_Vector.EnsureCount( index + 1 ); m_Vector[index] = item; } diff --git a/r5dev/public/tier1/utlsymbol.h b/r5dev/public/tier1/utlsymbol.h index 3133559d..70a3308e 100644 --- a/r5dev/public/tier1/utlsymbol.h +++ b/r5dev/public/tier1/utlsymbol.h @@ -196,60 +196,62 @@ private: }; -class CUtlSymbolTableMT : public CUtlSymbolTable -{ -public: - CUtlSymbolTableMT( int growSize = 0, int initSize = 32, bool caseInsensitive = false ) - : CUtlSymbolTable( growSize, initSize, caseInsensitive ) - { - } +// TODO[ AMOS ]: implement CThreadSpinRWLock - CUtlSymbol AddString( const char* pString ) - { - m_lock.LockForWrite(); - CUtlSymbol result = CUtlSymbolTable::AddString( pString ); - m_lock.UnlockWrite(); - return result; - } - - CUtlSymbol Find( const char* pString ) const - { - m_lock.LockForWrite(); - CUtlSymbol result = CUtlSymbolTable::Find( pString ); - m_lock.UnlockWrite(); - return result; - } - - const char* String( CUtlSymbol id ) const - { - m_lock.LockForRead(); - const char *pszResult = CUtlSymbolTable::String( id ); - m_lock.UnlockRead(); - return pszResult; - } - - const char * StringNoLock( CUtlSymbol id ) const - { - return CUtlSymbolTable::String( id ); - } - - void LockForRead() - { - m_lock.LockForRead(); - } - - void UnlockForRead() - { - m_lock.UnlockRead(); - } - -private: -#ifdef WIN32 - mutable CThreadSpinRWLock m_lock; -#else - mutable CThreadRWLock m_lock; -#endif -}; +//class CUtlSymbolTableMT : public CUtlSymbolTable +//{ +//public: +// CUtlSymbolTableMT( int growSize = 0, int initSize = 32, bool caseInsensitive = false ) +// : CUtlSymbolTable( growSize, initSize, caseInsensitive ) +// { +// } +// +// CUtlSymbol AddString( const char* pString ) +// { +// m_lock.LockForWrite(); +// CUtlSymbol result = CUtlSymbolTable::AddString( pString ); +// m_lock.UnlockWrite(); +// return result; +// } +// +// CUtlSymbol Find( const char* pString ) const +// { +// m_lock.LockForWrite(); +// CUtlSymbol result = CUtlSymbolTable::Find( pString ); +// m_lock.UnlockWrite(); +// return result; +// } +// +// const char* String( CUtlSymbol id ) const +// { +// m_lock.LockForRead(); +// const char *pszResult = CUtlSymbolTable::String( id ); +// m_lock.UnlockRead(); +// return pszResult; +// } +// +// const char * StringNoLock( CUtlSymbol id ) const +// { +// return CUtlSymbolTable::String( id ); +// } +// +// void LockForRead() +// { +// m_lock.LockForRead(); +// } +// +// void UnlockForRead() +// { +// m_lock.UnlockRead(); +// } +// +//private: +//#ifdef WIN32 +// mutable CThreadSpinRWLock m_lock; +//#else +// mutable CThreadRWLock m_lock; +//#endif +//}; @@ -268,68 +270,71 @@ typedef void* FileNameHandle_t; // Symbol table for more efficiently storing filenames by breaking paths and filenames apart. // Refactored from BaseFileSystem.h -class CUtlFilenameSymbolTable -{ - // Internal representation of a FileHandle_t - // If we get more than 64K filenames, we'll have to revisit... - // Right now CUtlSymbol is a short, so this packs into an int/void * pointer size... - struct FileNameHandleInternal_t - { - FileNameHandleInternal_t() - { - COMPILE_TIME_ASSERT( sizeof( *this ) == sizeof( FileNameHandle_t ) ); - COMPILE_TIME_ASSERT( sizeof( value ) == 4 ); - value = 0; -#ifdef PLATFORM_64BITS - pad = 0; -#endif - } +// TODO[ AMOS ]: implement CThreadSpinRWLock - // We pack the path and file values into a single 32 bit value. We were running - // out of space with the two 16 bit values (more than 64k files) so instead of increasing - // the total size we split the underlying pool into two (paths and files) and - // use a smaller path string pool and a larger file string pool. - unsigned int value; - -#ifdef PLATFORM_64BITS - // some padding to make sure we are the same size as FileNameHandle_t on 64 bit. - unsigned int pad; -#endif - - static const unsigned int cNumBitsInPath = 12; - static const unsigned int cNumBitsInFile = 32 - cNumBitsInPath; - - static const unsigned int cMaxPathValue = 1 << cNumBitsInPath; - static const unsigned int cMaxFileValue = 1 << cNumBitsInFile; - - static const unsigned int cPathBitMask = cMaxPathValue - 1; - static const unsigned int cFileBitMask = cMaxFileValue - 1; - - // Part before the final '/' character - unsigned int GetPath() const { return ((value >> cNumBitsInFile) & cPathBitMask); } - void SetPath( unsigned int path ) { Assert( path < cMaxPathValue ); value = ((value & cFileBitMask) | ((path & cPathBitMask) << cNumBitsInFile)); } - - // Part after the final '/', including extension - unsigned int GetFile() const { return (value & cFileBitMask); } - void SetFile( unsigned int file ) { Assert( file < cMaxFileValue ); value = ((value & (cPathBitMask << cNumBitsInFile)) | (file & cFileBitMask)); } - }; - -public: - FileNameHandle_t FindOrAddFileName( const char *pFileName ); - FileNameHandle_t FindFileName( const char *pFileName ); - int PathIndex( const FileNameHandle_t &handle ) { return (( const FileNameHandleInternal_t * )&handle)->GetPath(); } - bool String( const FileNameHandle_t& handle, char *buf, int buflen ); - void RemoveAll(); - void SpewStrings(); - bool SaveToBuffer( CUtlBuffer &buffer ); - bool RestoreFromBuffer( CUtlBuffer &buffer ); - -private: - CCountedStringPoolBase m_PathStringPool; - CCountedStringPoolBase m_FileStringPool; - mutable CThreadSpinRWLock m_lock; -}; +//class CUtlFilenameSymbolTable +//{ +// // Internal representation of a FileHandle_t +// // If we get more than 64K filenames, we'll have to revisit... +// // Right now CUtlSymbol is a short, so this packs into an int/void * pointer size... +// struct FileNameHandleInternal_t +// { +// FileNameHandleInternal_t() +// { +// COMPILE_TIME_ASSERT( sizeof( *this ) == sizeof( FileNameHandle_t ) ); +// COMPILE_TIME_ASSERT( sizeof( value ) == 4 ); +// value = 0; +// +//#ifdef PLATFORM_64BITS +// pad = 0; +//#endif +// } +// +// // We pack the path and file values into a single 32 bit value. We were running +// // out of space with the two 16 bit values (more than 64k files) so instead of increasing +// // the total size we split the underlying pool into two (paths and files) and +// // use a smaller path string pool and a larger file string pool. +// unsigned int value; +// +//#ifdef PLATFORM_64BITS +// // some padding to make sure we are the same size as FileNameHandle_t on 64 bit. +// unsigned int pad; +//#endif +// +// static const unsigned int cNumBitsInPath = 12; +// static const unsigned int cNumBitsInFile = 32 - cNumBitsInPath; +// +// static const unsigned int cMaxPathValue = 1 << cNumBitsInPath; +// static const unsigned int cMaxFileValue = 1 << cNumBitsInFile; +// +// static const unsigned int cPathBitMask = cMaxPathValue - 1; +// static const unsigned int cFileBitMask = cMaxFileValue - 1; +// +// // Part before the final '/' character +// unsigned int GetPath() const { return ((value >> cNumBitsInFile) & cPathBitMask); } +// void SetPath( unsigned int path ) { Assert( path < cMaxPathValue ); value = ((value & cFileBitMask) | ((path & cPathBitMask) << cNumBitsInFile)); } +// +// // Part after the final '/', including extension +// unsigned int GetFile() const { return (value & cFileBitMask); } +// void SetFile( unsigned int file ) { Assert( file < cMaxFileValue ); value = ((value & (cPathBitMask << cNumBitsInFile)) | (file & cFileBitMask)); } +// }; +// +//public: +// FileNameHandle_t FindOrAddFileName( const char *pFileName ); +// FileNameHandle_t FindFileName( const char *pFileName ); +// int PathIndex( const FileNameHandle_t &handle ) { return (( const FileNameHandleInternal_t * )&handle)->GetPath(); } +// bool String( const FileNameHandle_t& handle, char *buf, int buflen ); +// void RemoveAll(); +// void SpewStrings(); +// bool SaveToBuffer( CUtlBuffer &buffer ); +// bool RestoreFromBuffer( CUtlBuffer &buffer ); +// +//private: +// CCountedStringPoolBase m_PathStringPool; +// CCountedStringPoolBase m_FileStringPool; +// mutable CThreadSpinRWLock m_lock; +//}; // This creates a simple class that includes the underlying CUtlSymbol // as a private member and then instances a private symbol table to