diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index fd4ee26c0df..0f3ee3f9a24 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -90,10 +90,6 @@ PL_DHashStubEnumRemove(PLDHashTable *table, * * // HashKey(): calculate the hash number * static PLDHashNumber HashKey(KeyTypePointer aKey); - * - * // ALLOW_MEMMOVE can we move this class with memmove(), or do we have - * // to use the copy constructor? - * enum { ALLOW_MEMMOVE = PR_(TRUE or FALSE) }; * } * * @see nsInterfaceHashtable @@ -246,11 +242,9 @@ public: } protected: + static const PLDHashTableOps sOps; PLDHashTable mTable; - static const void* PR_CALLBACK s_GetKey(PLDHashTable *table, - PLDHashEntryHdr *entry); - static PLDHashNumber PR_CALLBACK s_HashKey(PLDHashTable *table, const void *key); @@ -258,10 +252,6 @@ protected: const PLDHashEntryHdr *entry, const void *key); - static void PR_CALLBACK s_CopyEntry(PLDHashTable *table, - const PLDHashEntryHdr *from, - PLDHashEntryHdr *to); - static void PR_CALLBACK s_ClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry); @@ -298,6 +288,20 @@ private: // template definitions // +template +const PLDHashTableOps +nsTHashtable::sOps = +{ + ::PL_DHashAllocTable, + ::PL_DHashFreeTable, + s_HashKey, + s_MatchEntry, + ::PL_DHashMoveEntryStub, + s_ClearEntry, + ::PL_DHashFinalizeStub, + s_InitEntry +}; + template nsTHashtable::nsTHashtable() { @@ -322,23 +326,6 @@ nsTHashtable::Init(PRUint32 initSize) return PR_TRUE; } - static PLDHashTableOps sOps = - { - ::PL_DHashAllocTable, - ::PL_DHashFreeTable, - s_HashKey, - s_MatchEntry, - ::PL_DHashMoveEntryStub, - s_ClearEntry, - ::PL_DHashFinalizeStub, - s_InitEntry - }; - - if (!EntryType::ALLOW_MEMMOVE) - { - sOps.moveEntry = s_CopyEntry; - } - if (!PL_DHashTableInit(&mTable, &sOps, nsnull, sizeof(EntryType), initSize)) { // if failed, reset "flag" @@ -369,20 +356,6 @@ nsTHashtable::s_MatchEntry(PLDHashTable *table, reinterpret_cast(key)); } -template -void -nsTHashtable::s_CopyEntry(PLDHashTable *table, - const PLDHashEntryHdr *from, - PLDHashEntryHdr *to) -{ - EntryType* fromEntry = - const_cast(reinterpret_cast(from)); - - new(to) EntryType(*fromEntry); - - fromEntry->~EntryType(); -} - template void nsTHashtable::s_ClearEntry(PLDHashTable *table,