Skip to content

Commit a7670ae

Browse files
committed
[GEN][ZH] Fix incorrect AsciiString hash implementation for non-stlport
1 parent fa996eb commit a7670ae

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Generals/Code/GameEngine/Include/Common/STLTypedefs.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ namespace rts
190190

191191
template<> struct hash<AsciiString>
192192
{
193-
size_t operator()(AsciiString ast) const
194-
{
193+
size_t operator()(const AsciiString& ast) const
194+
{
195+
#ifdef USING_STLPORT
195196
std::hash<const char *> tmp;
196197
return tmp((const char *) ast.str());
198+
#else
199+
// TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort.
200+
std::hash<std::string_view> hasher;
201+
return hasher(std::string_view(ast.str(), ast.getLength()));
202+
#endif
197203
}
198204
};
199205

GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ namespace rts
190190

191191
template<> struct hash<AsciiString>
192192
{
193-
size_t operator()(AsciiString ast) const
194-
{
193+
size_t operator()(const AsciiString& ast) const
194+
{
195+
#ifdef USING_STLPORT
195196
std::hash<const char *> tmp;
196197
return tmp((const char *) ast.str());
198+
#else
199+
// TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort.
200+
std::hash<std::string_view> hasher;
201+
return hasher(std::string_view(ast.str(), ast.getLength()));
202+
#endif
197203
}
198204
};
199205

0 commit comments

Comments
 (0)