Using nsHashtable and nsProgIDKey for dll hashing

git-svn-id: svn://10.0.0.236/trunk@23930 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dp%netscape.com
1999-03-12 11:25:17 +00:00
parent 2d294e429d
commit 9356d42ebe
4 changed files with 24 additions and 20 deletions

View File

@@ -47,7 +47,7 @@
#include "prlink.h"
#include "prsystem.h"
#include "prprf.h"
#include "xcDllStore.h"
#include "xcDll.h"
#include "prlog.h"
#include "prerror.h"
@@ -83,7 +83,7 @@ nsFactoryEntry::~nsFactoryEntry(void)
}
nsresult
nsFactoryEntry::Init(nsDllStore* dllCollection,
nsFactoryEntry::Init(nsHashtable* dllCollection,
const nsCID &aClass, const char *aLibrary,
PRTime lastModTime, PRUint32 fileSize)
{
@@ -92,9 +92,11 @@ nsFactoryEntry::Init(nsDllStore* dllCollection,
}
cid = aClass;
nsProgIDKey key(aLibrary);
// If dll not already in dllCollection, add it.
// PR_EnterMonitor(mMon);
dll = dllCollection->Get(aLibrary);
dll = (nsDll *) dllCollection->Get(&key);
// PR_ExitMonitor(mMon);
if (dll == NULL) {
@@ -118,7 +120,7 @@ nsFactoryEntry::Init(nsDllStore* dllCollection,
aLibrary));
// PR_EnterMonitor(mMon);
dllCollection->Put(aLibrary, dll);
dllCollection->Put(&key, (void *)dll);
// PR_ExitMonitor(mMon);
}
}
@@ -161,7 +163,7 @@ nsresult nsComponentManagerImpl::Init(void)
return NS_ERROR_OUT_OF_MEMORY;
}
if (mDllStore == NULL) {
mDllStore = new nsDllStore();
mDllStore = new nsHashtable();
if (mDllStore == NULL)
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -1752,7 +1754,8 @@ nsComponentManagerImpl::SyncComponentsInFile(const char *fullname)
}
// Check if dll is one that we have already seen
nsDll *dll = mDllStore->Get(fullname);
nsProgIDKey key(fullname);
nsDll *dll = (nsDll *) mDllStore->Get(&key);
nsresult rv = NS_OK;
if (dll == NULL)
{
@@ -1851,7 +1854,7 @@ nsComponentManagerImpl::SyncComponentsInFile(const char *fullname)
dll = new nsDll(fullname);
if (dll == NULL)
return NS_ERROR_OUT_OF_MEMORY;
mDllStore->Put(fullname, dll);
mDllStore->Put(&key, (void *) dll);
} // dll == NULL
// Either we are seeing the dll for the first time or the dll has

View File

@@ -26,7 +26,6 @@
#include "prmon.h"
class nsFactoryEntry;
class nsDllStore;
class nsDll;
////////////////////////////////////////////////////////////////////////////////
@@ -170,7 +169,7 @@ protected:
nsHashtable* mFactories;
nsHashtable* mProgIDs;
PRMonitor* mMon;
nsDllStore* mDllStore;
nsHashtable* mDllStore;
};
#define NS_MAX_FILENAME_LEN 1024
@@ -231,7 +230,7 @@ public:
nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory);
~nsFactoryEntry();
nsresult Init(nsDllStore* store, const nsCID &aClass, const char *aLibrary,
nsresult Init(nsHashtable* dllHashtable, const nsCID &aClass, const char *aLibrary,
PRTime lastModTime, PRUint32 fileSize);
nsCID cid;

View File

@@ -47,7 +47,7 @@
#include "prlink.h"
#include "prsystem.h"
#include "prprf.h"
#include "xcDllStore.h"
#include "xcDll.h"
#include "prlog.h"
#include "prerror.h"
@@ -83,7 +83,7 @@ nsFactoryEntry::~nsFactoryEntry(void)
}
nsresult
nsFactoryEntry::Init(nsDllStore* dllCollection,
nsFactoryEntry::Init(nsHashtable* dllCollection,
const nsCID &aClass, const char *aLibrary,
PRTime lastModTime, PRUint32 fileSize)
{
@@ -92,9 +92,11 @@ nsFactoryEntry::Init(nsDllStore* dllCollection,
}
cid = aClass;
nsProgIDKey key(aLibrary);
// If dll not already in dllCollection, add it.
// PR_EnterMonitor(mMon);
dll = dllCollection->Get(aLibrary);
dll = (nsDll *) dllCollection->Get(&key);
// PR_ExitMonitor(mMon);
if (dll == NULL) {
@@ -118,7 +120,7 @@ nsFactoryEntry::Init(nsDllStore* dllCollection,
aLibrary));
// PR_EnterMonitor(mMon);
dllCollection->Put(aLibrary, dll);
dllCollection->Put(&key, (void *)dll);
// PR_ExitMonitor(mMon);
}
}
@@ -161,7 +163,7 @@ nsresult nsComponentManagerImpl::Init(void)
return NS_ERROR_OUT_OF_MEMORY;
}
if (mDllStore == NULL) {
mDllStore = new nsDllStore();
mDllStore = new nsHashtable();
if (mDllStore == NULL)
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -1752,7 +1754,8 @@ nsComponentManagerImpl::SyncComponentsInFile(const char *fullname)
}
// Check if dll is one that we have already seen
nsDll *dll = mDllStore->Get(fullname);
nsProgIDKey key(fullname);
nsDll *dll = (nsDll *) mDllStore->Get(&key);
nsresult rv = NS_OK;
if (dll == NULL)
{
@@ -1851,7 +1854,7 @@ nsComponentManagerImpl::SyncComponentsInFile(const char *fullname)
dll = new nsDll(fullname);
if (dll == NULL)
return NS_ERROR_OUT_OF_MEMORY;
mDllStore->Put(fullname, dll);
mDllStore->Put(&key, (void *) dll);
} // dll == NULL
// Either we are seeing the dll for the first time or the dll has

View File

@@ -26,7 +26,6 @@
#include "prmon.h"
class nsFactoryEntry;
class nsDllStore;
class nsDll;
////////////////////////////////////////////////////////////////////////////////
@@ -170,7 +169,7 @@ protected:
nsHashtable* mFactories;
nsHashtable* mProgIDs;
PRMonitor* mMon;
nsDllStore* mDllStore;
nsHashtable* mDllStore;
};
#define NS_MAX_FILENAME_LEN 1024
@@ -231,7 +230,7 @@ public:
nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory);
~nsFactoryEntry();
nsresult Init(nsDllStore* store, const nsCID &aClass, const char *aLibrary,
nsresult Init(nsHashtable* dllHashtable, const nsCID &aClass, const char *aLibrary,
PRTime lastModTime, PRUint32 fileSize);
nsCID cid;