Introduce NameHashSet (bug 5884 part 1, r=ds).

This commit is contained in:
David Anderson
2013-08-25 11:59:44 -07:00
parent db1b7a8067
commit 0144062126
4 changed files with 281 additions and 10 deletions
+4 -8
View File
@@ -981,12 +981,10 @@ CGameConfig::AddressConf::AddressConf(char *sigName, unsigned sigLength, unsigne
SendProp *CGameConfig::GetSendProp(const char *key)
{
SendProp **pProp;
if ((pProp = m_Props.retrieve(key)) == NULL)
SendProp *prop;
if (!m_Props.retrieve(key, &prop))
return NULL;
return *pProp;
return prop;
}
bool CGameConfig::GetMemSig(const char *key, void **addr)
@@ -1042,11 +1040,9 @@ bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pCon
#endif
CGameConfig *pConfig;
CGameConfig **ppConfig;
if ((ppConfig = m_Lookup.retrieve(file)) != NULL)
if (m_Lookup.retrieve(file, &pConfig))
{
pConfig = *ppConfig;
pConfig->AddRef();
*_pConfig = pConfig;
return true;
+8 -2
View File
@@ -39,6 +39,7 @@
#include <sm_trie_tpl.h>
#include <am-refcounting.h>
#include <sm_stringhashmap.h>
#include <sm_namehashset.h>
using namespace SourceMod;
using namespace SourceHook;
@@ -69,12 +70,17 @@ public: //IGameConfig
SendProp *GetSendProp(const char *key);
bool GetMemSig(const char *key, void **addr);
bool GetAddress(const char *key, void **addr);
public: //NameHashSet
static inline bool matches(const char *key, const CGameConfig *value)
{
return strcmp(key, value->m_File) == 0;
}
private:
ke::AutoPtr<BaseStringTable> m_pStrings;
char m_File[PLATFORM_MAX_PATH];
char m_CurFile[PLATFORM_MAX_PATH];
StringHashMap<int> m_Offsets;
KTrie<SendProp *> m_Props;
StringHashMap<SendProp *> m_Props;
StringHashMap<int> m_Keys;
StringHashMap<void *> m_Sigs;
/* Parse states */
@@ -139,7 +145,7 @@ public: //SMGlobalClass
public:
void RemoveCachedConfig(CGameConfig *config);
private:
KTrie<CGameConfig *> m_Lookup;
NameHashSet<CGameConfig *> m_Lookup;
public:
StringHashMap<ITextListener_SMC *> m_customHandlers;
};