Skip to content

Commit 6306bda

Browse files
committed
Upgrade std hash structures
1 parent 3cf0474 commit 6306bda

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

src/xrCommon/xr_unordered_map.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
#pragma once
2-
// XXX: upgrade std hash structures
3-
#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
4-
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
5-
#endif
6-
#include <hash_map>
72
#include <unordered_map>
83
#include "xrCore/Memory/XRayAllocator.hpp"
94

10-
template <typename K, class V, class _Traits = stdext::hash_compare<K, std::less<K>>, typename allocator = XRay::xray_allocator<std::pair<K, V>>>
11-
using xr_hash_map = stdext::hash_map<K, V, _Traits, allocator>;
12-
13-
template<class Key, class T, class Hasher = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class allocator = XRay::xray_allocator<std::pair<const Key, T>>>
5+
template <class Key, class T, class Hasher = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
6+
class allocator = XRay::xray_allocator<std::pair<const Key, T>>>
147
using xr_unordered_map = std::unordered_map<Key, T, Hasher, KeyEqual, allocator>;

src/xrCore/xrCore.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
// XXX: upgrade std hash structures
4-
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
53
#ifndef DEBUG
64
#define MASTER_GOLD
75
#endif // DEBUG

src/xrGame/xrServer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
class CSE_Abstract;
2424

25-
const u32 NET_Latency = 50; // time in (ms)
25+
constexpr u32 NET_Latency = 50; // time in (ms)
2626

27-
// t-defs
28-
typedef xr_hash_map<u16, CSE_Abstract*> xrS_entities;
27+
// XXX: check if u16 used for entity's id. If true, then this must be changed, if we want to increase the number of ID's.
28+
using xrS_entities = xr_unordered_map<u16, CSE_Abstract*>;
2929

3030
class xrClientData : public IClient
3131
{

src/xrScriptEngine/script_engine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bool RunJITCommand(lua_State* ls, const char* command)
110110

111111
const char* const CScriptEngine::GlobalNamespace = SCRIPT_GLOBAL_NAMESPACE;
112112
Lock CScriptEngine::stateMapLock;
113-
xr_hash_map<lua_State*, CScriptEngine*>* CScriptEngine::stateMap = nullptr;
113+
xr_unordered_map<lua_State*, CScriptEngine*>* CScriptEngine::stateMap = nullptr;
114114

115115
string4096 CScriptEngine::g_ca_stdout;
116116

@@ -119,7 +119,7 @@ void CScriptEngine::reinit()
119119
stateMapLock.Enter();
120120
if (!stateMap)
121121
{
122-
stateMap = new xr_hash_map<lua_State*, CScriptEngine*>();
122+
stateMap = new xr_unordered_map<lua_State*, CScriptEngine*>();
123123
stateMap->reserve(32); // 32 lua states should be enough
124124
}
125125
stateMapLock.Leave();

src/xrScriptEngine/script_engine.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class XRSCRIPTENGINE_API CScriptEngine
7575

7676
private:
7777
static Lock stateMapLock;
78-
static xr_hash_map<lua_State*, CScriptEngine*>* stateMap;
78+
static xr_unordered_map<lua_State*, CScriptEngine*>* stateMap;
7979
lua_State* m_virtual_machine;
8080
CScriptThread* m_current_thread;
8181
bool m_reload_modules;

0 commit comments

Comments
 (0)