mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-20 04:26:03 +08:00
Improve CUtlStringToken string constructor
Prevent hashing attempts on emtpy or null strings
This commit is contained in:
@ -31,11 +31,15 @@ class CUtlStringToken
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FORCEINLINE CUtlStringToken( uint32 nHashCode = 0 ) : m_nHashCode( nHashCode ) {}
|
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(g_bUpdateStringTokenDatabase)
|
if(str && *str)
|
||||||
{
|
{
|
||||||
RegisterStringToken( m_nHashCode, str, 0, true );
|
m_nHashCode = MurmurHash2LowerCase( str, STRINGTOKEN_MURMURHASH_SEED );
|
||||||
|
if(g_bUpdateStringTokenDatabase)
|
||||||
|
{
|
||||||
|
RegisterStringToken( m_nHashCode, str, 0, true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user