mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Remove double hash lookup.
Added extra add ref to cache r=jband (submitted by him)
This commit is contained in:
parent
2f30889014
commit
359cd1e026
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user