diff --git a/mozilla/xpcom/ds/nsAtomTable.cpp b/mozilla/xpcom/ds/nsAtomTable.cpp index f6eaba2900a..b37ae4091ca 100644 --- a/mozilla/xpcom/ds/nsAtomTable.cpp +++ b/mozilla/xpcom/ds/nsAtomTable.cpp @@ -80,12 +80,8 @@ AtomImpl::~AtomImpl() { NS_PRECONDITION(nsnull != gAtomHashTable, "null atom hashtable"); if (nsnull != gAtomHashTable) { - // The hash table uses nsAReadableString& as the key so we must - // instanciate a nsAReadableString (nsLiteralString) and use that - // as the key - nsLiteralString key(mString); - PL_HashTableRemove(gAtomHashTable, &key); + PL_HashTableRemove(gAtomHashTable, mString); nsrefcnt cnt = --gAtoms; if (0 == cnt) { // When the last atom is destroyed, the atom arena is destroyed @@ -98,33 +94,6 @@ AtomImpl::~AtomImpl() NS_IMPL_THREADSAFE_ISUPPORTS1(AtomImpl, nsIAtom) -class CalculateHash - { - public: - typedef PRUnichar value_type; - - CalculateHash() : mHash(0), mLengthHashed(0) { } - - - PRUint32 - write( const PRUnichar* s, PRUint32 N ) - { - for ( PRUint32 n=0; n hashBegin, hashEnd; - copy_string(k->BeginReading(hashBegin), k->EndReading(hashEnd), hasher); + PRUint32 hashResult = 0; + PRUint32 N = nsCRT::strlen(k); - return NS_STATIC_CAST(PLHashNumber, hasher.GetHash()); + for ( PRUint32 n=0; n hashBegin, hashEnd; - copy_string(aString.BeginReading(hashBegin), aString.EndReading(hashEnd), hasher); + const PRUnichar *str = nsPromiseFlatString(aString).get(); - PRUint32 hashCode = hasher.GetHash(); + PRUint32 hashCode = HashKey(str); + + PLHashEntry** hep = PL_HashTableRawLookup(gAtomHashTable, hashCode, str); - PLHashEntry** hep = PL_HashTableRawLookup(gAtomHashTable, hashCode, - &aString); PLHashEntry* he = *hep; AtomImpl* id; @@ -225,9 +194,9 @@ NS_COM nsIAtom* NS_NewAtom( const nsAReadableString& aString ) return id; } -NS_COM nsIAtom* NS_NewAtom( const PRUnichar* us ) +NS_COM nsIAtom* NS_NewAtom( const PRUnichar* str ) { - return NS_NewAtom(nsLiteralString(us)); + return NS_NewAtom(nsLiteralString(str)); } NS_COM nsrefcnt NS_GetNumberOfAtoms(void)