Remove CoreConfig use of memtables (bug 5899 part 1, r=fyren).
authorDavid Anderson <dvander@alliedmods.net>
Sat Aug 31 11:50:11 2013 -0700 (2013-08-31)
changeset 4110f1f4eb1d9274
parent 4109 10eb68d668af
child 4111 34b8688e3bec
Remove CoreConfig use of memtables (bug 5899 part 1, r=fyren).
core/CoreConfig.cpp
core/CoreConfig.h
public/amtl/am-string.h
     1.1 --- a/core/CoreConfig.cpp	Fri Aug 30 10:16:28 2013 -0700
     1.2 +++ b/core/CoreConfig.cpp	Sat Aug 31 11:50:11 2013 -0700
     1.3 @@ -124,7 +124,7 @@
     1.4  	g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL);
     1.5  }
     1.6  
     1.7 -CoreConfig::CoreConfig() : m_Strings(512)
     1.8 +CoreConfig::CoreConfig()
     1.9  {
    1.10  }
    1.11  
    1.12 @@ -257,7 +257,6 @@
    1.13  
    1.14  	/* Reset cached key values */
    1.15  	m_KeyValues.clear();
    1.16 -	m_Strings.Reset();
    1.17  
    1.18  	/* Parse config file */
    1.19  	if ((err=textparsers->ParseFile_SMC(filePath, this, NULL)) != SMCError_Okay)
    1.20 @@ -297,17 +296,18 @@
    1.21  		pBase = pBase->m_pGlobalClassNext;
    1.22  	}
    1.23  
    1.24 -	m_KeyValues.replace(option, m_Strings.AddString(value));
    1.25 +	ke::AString vstr(value);
    1.26 +	m_KeyValues.replace(option, ke::Move(vstr));
    1.27  
    1.28  	return ConfigResult_Ignore;
    1.29  }
    1.30  
    1.31  const char *CoreConfig::GetCoreConfigValue(const char *key)
    1.32  {
    1.33 -	int address;
    1.34 -	if (!m_KeyValues.retrieve(key, &address))
    1.35 +	StringHashMap<ke::AString>::Result r = m_KeyValues.find(key);
    1.36 +	if (!r.found())
    1.37  		return NULL;
    1.38 -	return m_Strings.GetString(address);
    1.39 +	return r->value.chars();
    1.40  }
    1.41  
    1.42  bool SM_AreConfigsExecuted()
     2.1 --- a/core/CoreConfig.h	Fri Aug 30 10:16:28 2013 -0700
     2.2 +++ b/core/CoreConfig.h	Sat Aug 31 11:50:11 2013 -0700
     2.3 @@ -35,8 +35,8 @@
     2.4  #include "sm_globals.h"
     2.5  #include <ITextParsers.h>
     2.6  #include <IRootConsoleMenu.h>
     2.7 +#include <am-string.h>
     2.8  #include <sm_stringhashmap.h>
     2.9 -#include "sm_memtable.h"
    2.10  
    2.11  using namespace SourceMod;
    2.12  
    2.13 @@ -68,8 +68,7 @@
    2.14  	 */
    2.15  	ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength);
    2.16  private:
    2.17 -	BaseStringTable m_Strings;
    2.18 -	StringHashMap<int> m_KeyValues;
    2.19 +	StringHashMap<ke::AString> m_KeyValues;
    2.20  };
    2.21  
    2.22  extern bool SM_AreConfigsExecuted();
     3.1 --- a/public/amtl/am-string.h	Fri Aug 30 10:16:28 2013 -0700
     3.2 +++ b/public/amtl/am-string.h	Sat Aug 31 11:50:11 2013 -0700
     3.3 @@ -45,6 +45,7 @@
     3.4     : length_(0)
     3.5    {
     3.6    }
     3.7 +
     3.8    explicit AString(const char *str) {
     3.9      set(str, strlen(str));
    3.10    }
    3.11 @@ -80,6 +81,12 @@
    3.12      }
    3.13      return *this;
    3.14    }
    3.15 +  AString &operator =(Moveable<AString> other) {
    3.16 +    chars_ = other->chars_.take();
    3.17 +    length_ = other->length_;
    3.18 +    other->length_ = 0;
    3.19 +    return *this;
    3.20 +  }
    3.21  
    3.22    int compare(const char *str) const {
    3.23      return strcmp(chars(), str);