Switch ConVar, CoreConfig off KTrie (bug 5884 part 8, r=ds).

This commit is contained in:
David Anderson 2013-08-25 12:13:30 -07:00
parent 3850765759
commit 77c7b312ea
4 changed files with 16 additions and 22 deletions

View File

@ -33,7 +33,7 @@
#include "sm_srvcmds.h"
#include "sm_stringutil.h"
#include <sh_vector.h>
#include <sm_trie_tpl.h>
#include <sm_namehashset.h>
#include "logic_bridge.h"
ConVarManager g_ConVarManager;
@ -54,7 +54,7 @@ SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB
const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String};
typedef List<const ConVar *> ConVarList;
KTrie<ConVarInfo *> convar_cache;
NameHashSet<ConVarInfo *> convar_cache;
class ConVarReentrancyGuard
{
@ -245,16 +245,7 @@ void ConVarManager::OnSourceModVSPReceived()
bool convar_cache_lookup(const char *name, ConVarInfo **pVar)
{
ConVarInfo **pLookup = convar_cache.retrieve(name);
if (pLookup != NULL)
{
*pVar = *pLookup;
return true;
}
else
{
return false;
}
return convar_cache.retrieve(name, pVar);
}
void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)

View File

@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@ -65,6 +65,11 @@ struct ConVarInfo
IChangeableForward *pChangeForward; /**< Forward associated with convar */
ConVar *pVar; /**< The actual convar */
List<IConVarChangeListener *> changeListeners;
static inline bool matches(const char *name, const ConVarInfo *info)
{
return strcmp(name, info->pVar->GetName()) == 0;
}
};
/**

View File

@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@ -304,12 +304,10 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value,
const char *CoreConfig::GetCoreConfigValue(const char *key)
{
int *pKey = m_KeyValues.retrieve(key);
if (pKey == NULL)
{
int address;
if (!m_KeyValues.retrieve(key, &address))
return NULL;
}
return m_Strings.GetString(*pKey);
return m_Strings.GetString(address);
}
bool SM_AreConfigsExecuted()

View File

@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@ -35,7 +35,7 @@
#include "sm_globals.h"
#include <ITextParsers.h>
#include <IRootConsoleMenu.h>
#include <sm_trie_tpl.h>
#include <sm_stringhashmap.h>
#include "sm_memtable.h"
using namespace SourceMod;
@ -69,7 +69,7 @@ private:
ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength);
private:
BaseStringTable m_Strings;
KTrie<int> m_KeyValues;
StringHashMap<int> m_KeyValues;
};
extern bool SM_AreConfigsExecuted();