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