Skip to content

Commit a8a158e

Browse files
Починить запуск игры -> "Схлопнуть с кешем хмл"
1 parent efecdbe commit a8a158e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/xrCore/FormatParsers/XML/xrXMLParser.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
#include "xrXMLParser.h"
55
#include "AsureXML.h"
66

7-
static xr_hash_map<xr_string, xr_shared_ptr<xr_string>> g_xmlCache;
7+
static xr_hash_map<xr_string, xr_shared_ptr<xr_string>>& GetXMLCache()
8+
{
9+
static xr_hash_map<xr_string, xr_shared_ptr<xr_string>> g_xmlCache;
10+
return g_xmlCache;
11+
}
812

913
void CXml::InvalidateCache()
1014
{
11-
g_xmlCache.clear();
15+
GetXMLCache().clear();
1216
Msg("XML cache invalidated");
1317
}
1418

@@ -150,8 +154,9 @@ bool CXml::Load(LPCSTR path, LPCSTR xml_filename)
150154
xr_shared_ptr<xr_string> cachedContent;
151155

152156
{
153-
auto it = g_xmlCache.find(cacheKey);
154-
if (it != g_xmlCache.end())
157+
auto& Cache = GetXMLCache();
158+
auto it = Cache.find(cacheKey);
159+
if (it != Cache.end())
155160
{
156161
cachedContent = it->second;
157162
}
@@ -217,10 +222,11 @@ bool CXml::Load(LPCSTR path, LPCSTR xml_filename)
217222

218223
cachedContent = xr_make_shared<xr_string>(printer.CStr());
219224
{
220-
auto it = g_xmlCache.find(cacheKey);
221-
if (it == g_xmlCache.end())
225+
auto& Cache = GetXMLCache();
226+
auto it = Cache.find(cacheKey);
227+
if (it == Cache.end())
222228
{
223-
g_xmlCache.emplace(cacheKey, cachedContent);
229+
Cache.emplace(cacheKey, cachedContent);
224230
}
225231
else
226232
{

0 commit comments

Comments
 (0)