mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Improve CUtlStringToken string constructor
Prevent hashing attempts on emtpy or null strings
This commit is contained in:
@ -31,13 +31,17 @@ class CUtlStringToken
|
||||
{
|
||||
public:
|
||||
FORCEINLINE CUtlStringToken( uint32 nHashCode = 0 ) : m_nHashCode( nHashCode ) {}
|
||||
FORCEINLINE CUtlStringToken( const char *str ) : m_nHashCode( MurmurHash2LowerCase( str, STRINGTOKEN_MURMURHASH_SEED ) )
|
||||
FORCEINLINE CUtlStringToken( const char *str ) : m_nHashCode( 0 )
|
||||
{
|
||||
if(str && *str)
|
||||
{
|
||||
m_nHashCode = MurmurHash2LowerCase( str, STRINGTOKEN_MURMURHASH_SEED );
|
||||
if(g_bUpdateStringTokenDatabase)
|
||||
{
|
||||
RegisterStringToken( m_nHashCode, str, 0, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE bool operator==( CUtlStringToken const &other ) const { return ( other.m_nHashCode == m_nHashCode ); }
|
||||
FORCEINLINE bool operator!=( CUtlStringToken const &other ) const { return !operator==( other ); }
|
||||
|
Reference in New Issue
Block a user