diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index dc6bb3da..97993f0c 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -124,7 +124,7 @@ void CoreConfig::OnSourceModAllInitialized() g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); } -CoreConfig::CoreConfig() : m_Strings(512) +CoreConfig::CoreConfig() { } @@ -257,7 +257,6 @@ void CoreConfig::Initialize() /* Reset cached key values */ m_KeyValues.clear(); - m_Strings.Reset(); /* Parse config file */ if ((err=textparsers->ParseFile_SMC(filePath, this, NULL)) != SMCError_Okay) @@ -297,17 +296,18 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, pBase = pBase->m_pGlobalClassNext; } - m_KeyValues.replace(option, m_Strings.AddString(value)); + ke::AString vstr(value); + m_KeyValues.replace(option, ke::Move(vstr)); return ConfigResult_Ignore; } const char *CoreConfig::GetCoreConfigValue(const char *key) { - int address; - if (!m_KeyValues.retrieve(key, &address)) + StringHashMap::Result r = m_KeyValues.find(key); + if (!r.found()) return NULL; - return m_Strings.GetString(address); + return r->value.chars(); } bool SM_AreConfigsExecuted() diff --git a/core/CoreConfig.h b/core/CoreConfig.h index 3a5b5dd2..6208e9bc 100644 --- a/core/CoreConfig.h +++ b/core/CoreConfig.h @@ -35,8 +35,8 @@ #include "sm_globals.h" #include #include +#include #include -#include "sm_memtable.h" using namespace SourceMod; @@ -68,8 +68,7 @@ private: */ ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength); private: - BaseStringTable m_Strings; - StringHashMap m_KeyValues; + StringHashMap m_KeyValues; }; extern bool SM_AreConfigsExecuted(); diff --git a/public/amtl/am-string.h b/public/amtl/am-string.h index 665e7bb8..1d1b7e2a 100644 --- a/public/amtl/am-string.h +++ b/public/amtl/am-string.h @@ -45,6 +45,7 @@ class AString : length_(0) { } + explicit AString(const char *str) { set(str, strlen(str)); } @@ -80,6 +81,12 @@ class AString } return *this; } + AString &operator =(Moveable other) { + chars_ = other->chars_.take(); + length_ = other->length_; + other->length_ = 0; + return *this; + } int compare(const char *str) const { return strcmp(chars(), str);