diff --git a/src/Cache.h b/src/Cache.h index 1fcb4ac..9894824 100644 --- a/src/Cache.h +++ b/src/Cache.h @@ -14,7 +14,7 @@ namespace Cache using Lock = std::mutex; using Locker = std::scoped_lock; - mutable Lock _lock; - ankerl::unordered_dense::map _formIDToEditorIDMap; + mutable Lock _lock; + Map _formIDToEditorIDMap; }; } diff --git a/src/PCH.h b/src/PCH.h index cf3f98a..c0f56b4 100644 --- a/src/PCH.h +++ b/src/PCH.h @@ -21,6 +21,23 @@ namespace ini = clib_util::ini; using namespace std::literals; using namespace clib_util::singleton; +template +using Map = ankerl::unordered_dense::map; + +struct string_hash +{ + using is_transparent = void; // enable heterogeneous overloads + using is_avalanching = void; // mark class as high quality avalanching hash + + [[nodiscard]] std::uint64_t operator()(std::string_view str) const noexcept + { + return ankerl::unordered_dense::hash{}(str); + } +}; + +template +using StringMap = ankerl::unordered_dense::map>; + namespace stl { using namespace SKSE::stl; @@ -54,11 +71,6 @@ namespace stl { write_vfunc(); } - - inline std::string as_string(std::string_view a_view) - { - return { a_view.data(), a_view.size() }; - } } #ifdef SKYRIM_AE diff --git a/src/Settings.cpp b/src/Settings.cpp index d6ca973..1139d8f 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -28,7 +28,7 @@ void Settings::Load() bool Settings::IsTweakInstalled(std::string_view a_tweak) { - const auto it = settingsMap.find(stl::as_string(a_tweak)); + const auto it = settingsMap.find(a_tweak); return it != settingsMap.end() ? it->second : false; } diff --git a/src/Settings.h b/src/Settings.h index 125c99d..3cc4aff 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -112,5 +112,5 @@ class Settings : public ISingleton Tweaks tweaks{}; Experimental experimental{}; - ankerl::unordered_dense::map settingsMap{}; + StringMap settingsMap{}; };