diff --git a/src/openrct2/core/String.hpp b/src/openrct2/core/String.hpp index da52e289d3..113f4977d7 100644 --- a/src/openrct2/core/String.hpp +++ b/src/openrct2/core/String.hpp @@ -19,6 +19,24 @@ namespace OpenRCT2::String { + struct Hash + { + using is_transparent = void; + + size_t operator()(const char* txt) const + { + return std::hash{}(txt); + } + size_t operator()(std::string_view txt) const + { + return std::hash{}(txt); + } + size_t operator()(const std::string& txt) const + { + return std::hash{}(txt); + } + }; + std::string toStd(const utf8* str); std::string toUtf8(std::wstring_view src); std::wstring toWideChar(std::string_view src); diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 2fe05c3b04..ad54541eae 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -69,7 +69,7 @@ struct ObjectEntryEqual } }; -using ObjectIdentifierMap = std::unordered_map; +using ObjectIdentifierMap = std::unordered_map>; using ObjectEntryMap = std::unordered_map; class ObjectFileIndex final : public FileIndex @@ -235,7 +235,7 @@ public: const ObjectRepositoryItem* FindObject(std::string_view identifier) const override final { - auto kvp = _newItemMap.find(std::string(identifier)); + auto kvp = _newItemMap.find(identifier); if (kvp != _newItemMap.end()) { return &_items[kvp->second];