Bug 983899, part 2 - Convert nsXBLService::gClassTable to nsDataHashtable. r=mrbkap

This commit is contained in:
Andrew McCreight 2014-03-18 14:25:39 -07:00
Родитель ba04fda1b5
Коммит a05294dd80
3 изменённых файлов: 12 добавлений и 22 удалений

Просмотреть файл

@ -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<nsXBLJSClass*>(nsXBLService::gClassTable->Get(k));
return nsXBLService::gClassTable->Get(k);
}
// Implementation /////////////////////////////////////////////////////////////////
@ -995,9 +987,8 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle<JSObject*> 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<JSObject*> 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<JSObject*> 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<JSObject*> 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();

Просмотреть файл

@ -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<nsXBLJSClass>* 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<nsXBLJSClass>();
Preferences::AddBoolVarCache(&gAllowDataURIs, "layout.debug.enable_data_xbl");

Просмотреть файл

@ -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<nsCStringHashKey, nsXBLJSClass*> ClassTable;
static ClassTable* gClassTable; // A table of nsXBLJSClass objects.
static mozilla::LinkedList<nsXBLJSClass>* 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<nsXBLJSClass>