diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 4141bf16..07514749 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -33,7 +33,7 @@ #include "sm_srvcmds.h" #include "sm_stringutil.h" #include -#include +#include #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 ConVarList; -KTrie convar_cache; +NameHashSet 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) diff --git a/core/ConVarManager.h b/core/ConVarManager.h index 9637dbb1..2e77d2d2 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -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 changeListeners; + + static inline bool matches(const char *name, const ConVarInfo *info) + { + return strcmp(name, info->pVar->GetName()) == 0; + } }; /** diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index e29b9ff6..dc6bb3da 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -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() diff --git a/core/CoreConfig.h b/core/CoreConfig.h index 6bf28591..3a5b5dd2 100644 --- a/core/CoreConfig.h +++ b/core/CoreConfig.h @@ -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 #include -#include +#include #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 m_KeyValues; + StringHashMap m_KeyValues; }; extern bool SM_AreConfigsExecuted();