fix a few problems introduced in #1730

https://github.com/bulletphysics/bullet3/pull/1730
This commit is contained in:
erwincoumans
2018-06-05 09:16:00 -07:00
parent d7cbe8dd26
commit fa648a028e
2 changed files with 22 additions and 35 deletions

View File

@@ -23,7 +23,7 @@ subject to the following restrictions:
///very basic hashable string implementation, compatible with btHashMap
struct btHashString
{
std::string m_string;
std::string m_string1;
unsigned int m_hash;
SIMD_FORCE_INLINE unsigned int getHash()const
@@ -33,11 +33,11 @@ struct btHashString
btHashString()
{
m_string="";
m_string1="";
m_hash=0;
}
btHashString(const char* name)
:m_string(name)
:m_string1(name)
{
/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */
static const unsigned int InitialFNV = 2166136261u;
@@ -46,36 +46,18 @@ struct btHashString
/* Fowler / Noll / Vo (FNV) Hash */
unsigned int hash = InitialFNV;
for(int i = 0; m_string[i]; i++)
for(int i = 0; m_string1.c_str()[i]; i++)
{
hash = hash ^ (m_string[i]); /* xor the low 8 bits */
hash = hash ^ (m_string1.c_str()[i]); /* xor the low 8 bits */
hash = hash * FNVMultiple; /* multiply by the magic number */
}
m_hash = hash;
}
int portableStringCompare(const char* src, const char* dst) const
{
int ret = 0 ;
while( ! (ret = *(const unsigned char *)src - *(const unsigned char *)dst) && *dst)
++src, ++dst;
if ( ret < 0 )
ret = -1 ;
else if ( ret > 0 )
ret = 1 ;
return( ret );
}
bool equals(const btHashString& other) const
{
return (m_string == other.m_string) ||
(0==portableStringCompare(m_string.c_str(),other.m_string.c_str()));
return (m_string1 == other.m_string1);
}
};
const int BT_HASH_NULL=0xffffffff;