Remove double hash lookup.
Added extra add ref to cache r=jband (submitted by him)
This commit is contained in:
Родитель
934a4efca1
Коммит
54929d4f0c
|
@ -37,7 +37,8 @@
|
|||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptcall.h"
|
||||
|
||||
|
||||
// LIFETIME_CACHE will cache class for the entire cyle of the application.
|
||||
#define LIFETIME_CACHE
|
||||
|
||||
static uint32 zero_methods_descriptor;
|
||||
|
||||
|
@ -82,9 +83,9 @@ nsProxyEventClass::GetNewOrUsedClass(REFNSIID aIID)
|
|||
nsCRT::free(iidStr);
|
||||
#endif
|
||||
|
||||
if(iidToClassMap->Exists(&key))
|
||||
{
|
||||
clazz = (nsProxyEventClass*) iidToClassMap->Get(&key);
|
||||
clazz = (nsProxyEventClass*) iidToClassMap->Get(&key);
|
||||
if(clazz)
|
||||
{
|
||||
NS_ADDREF(clazz);
|
||||
#ifdef PROXYEVENTCLASS_DEBUG
|
||||
char* iidStr = aIID.ToString();
|
||||
|
@ -160,6 +161,10 @@ nsProxyEventClass::nsProxyEventClass(REFNSIID aIID, nsIInterfaceInfo* aInfo)
|
|||
if (iidToClassMap != nsnull)
|
||||
{
|
||||
iidToClassMap->Put(&key, this);
|
||||
#ifdef LIFETIME_CACHE
|
||||
// extra addref to hold it in the cache
|
||||
NS_ADDREF_THIS();
|
||||
#endif
|
||||
#ifdef PROXYEVENTCLASS_DEBUG
|
||||
char* iidStr = aIID.ToString();
|
||||
printf("GetNewOrUsedClass %s put\n", iidStr);
|
||||
|
@ -190,6 +195,7 @@ nsProxyEventClass::~nsProxyEventClass()
|
|||
if(mDescriptors && mDescriptors != &zero_methods_descriptor)
|
||||
delete [] mDescriptors;
|
||||
|
||||
#ifndef LIFETIME_CACHE
|
||||
nsIDKey key(mIID);
|
||||
|
||||
nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
|
||||
|
@ -206,6 +212,7 @@ nsProxyEventClass::~nsProxyEventClass()
|
|||
nsCRT::free(iidStr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -171,10 +171,10 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
|||
|
||||
|
||||
// find in our hash table
|
||||
if(realToProxyMap->Exists(&rootkey))
|
||||
root = (nsProxyEventObject*) realToProxyMap->Get(&rootkey);
|
||||
if(root)
|
||||
{
|
||||
root = (nsProxyEventObject*) realToProxyMap->Get(&rootkey);
|
||||
proxy = root->Find(aIID);
|
||||
proxy = root->Find(aIID);
|
||||
|
||||
if(proxy)
|
||||
{
|
||||
|
|
|
@ -99,9 +99,20 @@ nsProxyObjectManager::nsProxyObjectManager()
|
|||
mProxyObjectMap = new nsHashtable(256, PR_TRUE);
|
||||
}
|
||||
|
||||
static PRBool PurgeProxyClasses(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
nsProxyEventClass* ptr = NS_REINTERPRET_CAST(nsProxyEventClass*, aData);
|
||||
NS_RELEASE(ptr);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsProxyObjectManager::~nsProxyObjectManager()
|
||||
{
|
||||
delete mProxyClassMap;
|
||||
if (mProxyClassMap)
|
||||
{
|
||||
mProxyClassMap->Reset(PurgeProxyClasses, nsnull);
|
||||
delete mProxyClassMap;
|
||||
}
|
||||
delete mProxyObjectMap;
|
||||
nsProxyObjectManager::mInstance = nsnull;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче