Added nsStr (nsString, nsString2) code for counting strings that have been seen. r=rickg

git-svn-id: svn://10.0.0.236/trunk@54036 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
warren%netscape.com
1999-11-20 04:22:26 +00:00
parent f9c524f923
commit eff6e0fd5e
7 changed files with 595 additions and 29 deletions

View File

@@ -269,29 +269,7 @@ nsStringKey::~nsStringKey(void)
PRUint32 nsStringKey::HashValue(void) const
{
if(mStr.IsUnicode())
{
PRUint32 h;
PRUint32 n;
PRUint32 m;
const PRUnichar* c;
h = 0;
n = mStr.Length();
c = mStr.GetUnicode();
if(n < 16)
{ /* Hash every char in a short string. */
for(; n; c++, n--)
h = (h >> 28) ^ (h << 4) ^ *c;
}
else
{ /* Sample a la jave.lang.String.hash(). */
for(m = n / 8; n >= m; c += m, n -= m)
h = (h >> 28) ^ (h << 4) ^ *c;
}
return h;
}
return (PRUint32)PL_HashString((const void*) mStr.GetBuffer());
return nsStr::HashCode(mStr);
}
PRBool nsStringKey::Equals(const nsHashKey* aKey) const