Remove memtables from GameConfigs (bug 5899 part 4, r=fyren).
Remove memtables from GameConfigs (
bug 5899 part 4, r=fyren).
1.1 --- a/core/logic/GameConfigs.cpp Sat Aug 31 19:50:15 2013 -0700
1.2 +++ b/core/logic/GameConfigs.cpp Sat Aug 31 19:50:26 2013 -0700
1.3 @@ -119,7 +119,6 @@
1.4 CGameConfig::CGameConfig(const char *file, const char *engine)
1.5 {
1.6 strncopy(m_File, file, sizeof(m_File));
1.7 - m_pStrings = new BaseStringTable(512);
1.8
1.9 m_CustomLevel = 0;
1.10 m_CustomHandler = NULL;
1.11 @@ -352,7 +351,8 @@
1.12 m_Offsets.replace(m_offset, atoi(value));
1.13 }
1.14 } else if (m_ParseState == PSTATE_GAMEDEFS_KEYS) {
1.15 - m_Keys.replace(key, m_pStrings->AddString(value));
1.16 + ke::AString vstr(value);
1.17 + m_Keys.replace(key, ke::Move(vstr));
1.18 } else if (m_ParseState == PSTATE_GAMEDEFS_SUPPORTED) {
1.19 if (strcmp(key, "game") == 0)
1.20 {
1.21 @@ -757,7 +757,6 @@
1.22 bool CGameConfig::Reparse(char *error, size_t maxlength)
1.23 {
1.24 /* Reset cached data */
1.25 - m_pStrings->Reset();
1.26 m_Offsets.clear();
1.27 m_Props.clear();
1.28 m_Keys.clear();
1.29 @@ -921,10 +920,10 @@
1.30
1.31 const char *CGameConfig::GetKeyValue(const char *key)
1.32 {
1.33 - int address;
1.34 - if (!m_Keys.retrieve(key, &address))
1.35 + StringHashMap<ke::AString>::Result r = m_Keys.find(key);
1.36 + if (!r.found())
1.37 return NULL;
1.38 - return m_pStrings->GetString(address);
1.39 + return r->value.chars();
1.40 }
1.41
1.42 //memory addresses below 0x10000 are automatically considered invalid for dereferencing
2.1 --- a/core/logic/GameConfigs.h Sat Aug 31 19:50:15 2013 -0700
2.2 +++ b/core/logic/GameConfigs.h Sat Aug 31 19:50:26 2013 -0700
2.3 @@ -35,7 +35,6 @@
2.4 #include "common_logic.h"
2.5 #include <IGameConfigs.h>
2.6 #include <ITextParsers.h>
2.7 -#include "sm_memtable.h"
2.8 #include <am-refcounting.h>
2.9 #include <sm_stringhashmap.h>
2.10 #include <sm_namehashset.h>
2.11 @@ -75,12 +74,11 @@
2.12 return strcmp(key, value->m_File) == 0;
2.13 }
2.14 private:
2.15 - ke::AutoPtr<BaseStringTable> m_pStrings;
2.16 char m_File[PLATFORM_MAX_PATH];
2.17 char m_CurFile[PLATFORM_MAX_PATH];
2.18 StringHashMap<int> m_Offsets;
2.19 StringHashMap<SendProp *> m_Props;
2.20 - StringHashMap<int> m_Keys;
2.21 + StringHashMap<ke::AString> m_Keys;
2.22 StringHashMap<void *> m_Sigs;
2.23 /* Parse states */
2.24 int m_ParseState;