diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp index e662646de4f5..a77fade6fd73 100644 --- a/dom/xbl/nsXBLBinding.cpp +++ b/dom/xbl/nsXBLBinding.cpp @@ -121,8 +121,7 @@ nsXBLJSClass::Destroy() "referenced nsXBLJSClass is on LRU list already!?"); if (nsXBLService::gClassTable) { - nsCStringKey key(mKey); - (nsXBLService::gClassTable)->Remove(&key); + nsXBLService::gClassTable->Remove(mKey); mKey.Truncate(); } @@ -141,14 +140,7 @@ nsXBLJSClass::Destroy() nsXBLJSClass* nsXBLService::getClass(const nsCString& k) { - nsCStringKey key(k); - return getClass(&key); -} - -nsXBLJSClass* -nsXBLService::getClass(nsCStringKey *k) -{ - return static_cast(nsXBLService::gClassTable->Get(k)); + return nsXBLService::gClassTable->Get(k); } // Implementation ///////////////////////////////////////////////////////////////// @@ -995,9 +987,8 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle global, // We need to initialize the class. *aNew = true; - nsCStringKey key(xblKey); if (!c) { - c = nsXBLService::getClass(&key); + c = nsXBLService::getClass(xblKey); } if (c) { // If c is on the LRU list, remove it now! @@ -1015,8 +1006,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle global, nsXBLService::gClassLRUListLength--; // Remove any mapping from the old name to the class struct. - nsCStringKey oldKey(c->Key()); - (nsXBLService::gClassTable)->Remove(&oldKey); + nsXBLService::gClassTable->Remove(c->Key()); // Change the class name and we're done. nsMemory::Free((void*) c->name); @@ -1025,7 +1015,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle global, } // Add c to our table. - (nsXBLService::gClassTable)->Put(&key, (void*)c); + nsXBLService::gClassTable->Put(xblKey, c); } // The prototype holds a strong reference to its class struct. @@ -1046,7 +1036,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle global, // This will happen if we're OOM or if the security manager // denies defining the new class... - (nsXBLService::gClassTable)->Remove(&key); + nsXBLService::gClassTable->Remove(xblKey); c->Drop(); diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index 5dcdd9113984..8c42e533f687 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -368,7 +368,7 @@ nsXBLStreamListener::HandleEvent(nsIDOMEvent* aEvent) // Static member variable initialization bool nsXBLService::gAllowDataURIs = false; -nsHashtable* nsXBLService::gClassTable = nullptr; +nsXBLService::ClassTable* nsXBLService::gClassTable = nullptr; LinkedList* nsXBLService::gClassLRUList = nullptr; uint32_t nsXBLService::gClassLRUListLength = 0; @@ -393,7 +393,7 @@ nsXBLService::Init() // Constructors/Destructors nsXBLService::nsXBLService(void) { - gClassTable = new nsHashtable(); + gClassTable = new ClassTable(); gClassLRUList = new LinkedList(); Preferences::AddBoolVarCache(&gAllowDataURIs, "layout.debug.enable_data_xbl"); diff --git a/dom/xbl/nsXBLService.h b/dom/xbl/nsXBLService.h index 637faac336e8..b7d0dab9db77 100644 --- a/dom/xbl/nsXBLService.h +++ b/dom/xbl/nsXBLService.h @@ -14,8 +14,9 @@ #include "nsWeakReference.h" #include "js/Class.h" // nsXBLJSClass derives from JSClass #include "nsTArray.h" +#include "nsDataHashtable.h" +#include "nsHashKeys.h" -class nsCStringKey; class nsXBLBinding; class nsXBLDocumentInfo; class nsXBLJSClass; @@ -24,7 +25,6 @@ class nsIDocument; class nsString; class nsIURI; class nsIPrincipal; -class nsHashtable; namespace mozilla { namespace dom { @@ -123,7 +123,8 @@ protected: public: static bool gDisableChromeCache; - static nsHashtable* gClassTable; // A table of nsXBLJSClass objects. + typedef nsDataHashtable ClassTable; + static ClassTable* gClassTable; // A table of nsXBLJSClass objects. static mozilla::LinkedList* gClassLRUList; // LRU list of cached classes. @@ -135,7 +136,6 @@ public: // Look up the class by key in gClassTable. static nsXBLJSClass *getClass(const nsCString &key); - static nsXBLJSClass *getClass(nsCStringKey *key); }; class nsXBLJSClass : public mozilla::LinkedListElement