Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54fa62d

Browse files
committedMar 27, 2025·
[GEN][ZH] Fix incorrect AsciiString hash implementation for non-stlport
1 parent 45b45cb commit 54fa62d

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
@@ -204,10 +204,16 @@ namespace rts
204204

205205
template<> struct hash<AsciiString>
206206
{
207-
size_t operator()(AsciiString ast) const
208-
{
207+
size_t operator()(const AsciiString& ast) const
208+
{
209+
#ifdef USING_STLPORT
209210
std::hash<const char *> tmp;
210211
return tmp((const char *) ast.str());
212+
#else
213+
// TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort.
214+
std::hash<std::string_view> hasher;
215+
return hasher(std::string_view(ast.str(), ast.getLength()));
216+
#endif
211217
}
212218
};
213219

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,16 @@ namespace rts
204204

205205
template<> struct hash<AsciiString>
206206
{
207-
size_t operator()(AsciiString ast) const
208-
{
207+
size_t operator()(const AsciiString& ast) const
208+
{
209+
#ifdef USING_STLPORT
209210
std::hash<const char *> tmp;
210211
return tmp((const char *) ast.str());
212+
#else
213+
// TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort.
214+
std::hash<std::string_view> hasher;
215+
return hasher(std::string_view(ast.str(), ast.getLength()));
216+
#endif
211217
}
212218
};
213219

0 commit comments

Comments
 (0)
Please sign in to comment.