mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-19 07:26:26 +00:00
Speed up nsCRT::HashCode(const PRUnichar*) by renaming the version that does UCS-2 to UTF-8 conversion to nsCRT::HashCodeAsUTF8. r=jag sr=jst b=120363
This commit is contained in:
parent
645e00764a
commit
030f6a08b1
@ -291,6 +291,20 @@ PRUint32 nsCRT::HashCode(const PRUnichar* str, PRUint32* resultingStrLen)
|
||||
|
||||
if (!str) return h;
|
||||
|
||||
PRUnichar c;
|
||||
while ( (c = *s++) )
|
||||
h = (h>>28) ^ (h<<4) ^ c;
|
||||
|
||||
if ( resultingStrLen )
|
||||
*resultingStrLen = (s-str)-1;
|
||||
return h;
|
||||
}
|
||||
|
||||
PRUint32 nsCRT::HashCodeAsUTF8(const PRUnichar* str, PRUint32* resultingStrLen)
|
||||
{
|
||||
PRUint32 h = 0;
|
||||
const PRUnichar* s = str;
|
||||
|
||||
{
|
||||
PRUint16 W1 = 0; // the first UTF-16 word in a two word tuple
|
||||
PRUint32 U = 0; // the current char as UCS-4
|
||||
|
@ -232,11 +232,21 @@ public:
|
||||
shared_allocator.deallocate(str, 0 /*we never new or kept the size*/);
|
||||
}
|
||||
|
||||
// Computes the hashcode for a c-string, returns the string length as an added bonus.
|
||||
static PRUint32 HashCode(const char* str, PRUint32* resultingStrLen = nsnull);
|
||||
// Computes the hashcode for a c-string, returns the string length as
|
||||
// an added bonus.
|
||||
static PRUint32 HashCode(const char* str,
|
||||
PRUint32* resultingStrLen = nsnull);
|
||||
|
||||
// Computes the hashcode for a ucs2 string, returns the string length as an added bonus.
|
||||
static PRUint32 HashCode(const PRUnichar* str, PRUint32* resultingStrLen = nsnull);
|
||||
// Computes the hashcode for a ucs2 string, returns the string length
|
||||
// as an added bonus.
|
||||
static PRUint32 HashCode(const PRUnichar* str,
|
||||
PRUint32* resultingStrLen = nsnull);
|
||||
|
||||
// Computes a hashcode for a ucs2 string that returns the same thing
|
||||
// as the HashCode method taking a |char*| would if the string were
|
||||
// converted to UTF8. Returns the string length as an added bonus.
|
||||
static PRUint32 HashCodeAsUTF8(const PRUnichar* str,
|
||||
PRUint32* resultingStrLen = nsnull);
|
||||
|
||||
// Computes the hashcode for a buffer with a specified length.
|
||||
static PRUint32 BufferHashCode(const char* str, PRUint32 strLen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user