From 241915d37bcf8c53260f0f191b4548cb8fe605ab Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 18 Dec 2016 13:24:04 +0100 Subject: [PATCH] [General] Use unordered_map where it makes sense --- src/Components/Modules/AssetHandler.cpp | 2 +- src/Components/Modules/Command.cpp | 4 ++-- src/Components/Modules/Command.hpp | 4 ++-- src/Components/Modules/Localization.cpp | 4 ++-- src/Components/Modules/Localization.hpp | 4 ++-- src/Components/Modules/Menus.cpp | 4 ++-- src/Components/Modules/Menus.hpp | 4 ++-- src/Components/Modules/ModelSurfs.cpp | 4 ++-- src/Components/Modules/ModelSurfs.hpp | 4 ++-- src/Components/Modules/MusicalTalent.cpp | 2 +- src/Components/Modules/MusicalTalent.hpp | 2 +- src/Components/Modules/Playlist.cpp | 2 +- src/Components/Modules/Playlist.hpp | 2 +- src/Components/Modules/StringTable.cpp | 2 +- src/Components/Modules/StringTable.hpp | 2 +- src/Components/Modules/UIFeeder.cpp | 2 +- src/Components/Modules/UIFeeder.hpp | 2 +- src/Components/Modules/UIScript.cpp | 4 ++-- src/Components/Modules/UIScript.hpp | 4 ++-- src/STDInclude.hpp | 1 + 20 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index e84920bb..d3a36639 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -409,7 +409,7 @@ namespace Components AssetHandler::~AssetHandler() { - ClearTemporaryAssets(); + AssetHandler::ClearTemporaryAssets(); for (auto i = AssetHandler::AssetInterfaces.begin(); i != AssetHandler::AssetInterfaces.end(); ++i) { diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 3370d16d..e5523bbd 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -3,8 +3,8 @@ namespace Components { Utils::Memory::Allocator Command::MemAllocator; - std::map> Command::FunctionMap; - std::map> Command::FunctionMapSV; + std::unordered_map> Command::FunctionMap; + std::unordered_map> Command::FunctionMapSV; std::string Command::Params::join(size_t startIndex) { diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index e61672de..fce3acc5 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -64,8 +64,8 @@ namespace Components private: static Utils::Memory::Allocator MemAllocator; - static std::map> FunctionMap; - static std::map> FunctionMapSV; + static std::unordered_map> FunctionMap; + static std::unordered_map> FunctionMapSV; static void MainCallback(); static void MainCallbackSV(); diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 09d1e0ce..8d195e90 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -5,8 +5,8 @@ namespace Components std::mutex Localization::LocalizeMutex; Dvar::Var Localization::UseLocalization; Utils::Memory::Allocator Localization::MemAllocator; - std::map Localization::LocalizeMap; - std::map Localization::TempLocalizeMap; + std::unordered_map Localization::LocalizeMap; + std::unordered_map Localization::TempLocalizeMap; void Localization::Set(std::string key, std::string value) { diff --git a/src/Components/Modules/Localization.hpp b/src/Components/Modules/Localization.hpp index 4492a2d7..70d42464 100644 --- a/src/Components/Modules/Localization.hpp +++ b/src/Components/Modules/Localization.hpp @@ -19,8 +19,8 @@ namespace Components private: static std::mutex LocalizeMutex; static Utils::Memory::Allocator MemAllocator; - static std::map LocalizeMap; - static std::map TempLocalizeMap; + static std::unordered_map LocalizeMap; + static std::unordered_map TempLocalizeMap; static Dvar::Var UseLocalization; static void __stdcall SetStringStub(const char* key, const char* value, bool isEnglish); diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index e4460e6a..5f655dee 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -3,8 +3,8 @@ namespace Components { std::vector Menus::CustomMenus; - std::map Menus::MenuList; - std::map Menus::MenuListList; + std::unordered_map Menus::MenuList; + std::unordered_map Menus::MenuListList; int Menus::ReserveSourceHandle() { diff --git a/src/Components/Modules/Menus.hpp b/src/Components/Modules/Menus.hpp index 1e25d02c..11af104b 100644 --- a/src/Components/Modules/Menus.hpp +++ b/src/Components/Modules/Menus.hpp @@ -18,8 +18,8 @@ namespace Components static void Add(std::string menu); private: - static std::map MenuList; - static std::map MenuListList; + static std::unordered_map MenuList; + static std::unordered_map MenuListList; static std::vector CustomMenus; static Game::XAssetHeader MenuLoad(Game::XAssetType type, std::string filename); diff --git a/src/Components/Modules/ModelSurfs.cpp b/src/Components/Modules/ModelSurfs.cpp index 03fa61e1..ec607c77 100644 --- a/src/Components/Modules/ModelSurfs.cpp +++ b/src/Components/Modules/ModelSurfs.cpp @@ -2,8 +2,8 @@ namespace Components { - std::map ModelSurfs::BufferMap; - std::map ModelSurfs::AllocMap; + std::unordered_map ModelSurfs::BufferMap; + std::unordered_map ModelSurfs::AllocMap; IUnknown* ModelSurfs::GetBuffer(void* buffer) { diff --git a/src/Components/Modules/ModelSurfs.hpp b/src/Components/Modules/ModelSurfs.hpp index 45290882..ecea211b 100644 --- a/src/Components/Modules/ModelSurfs.hpp +++ b/src/Components/Modules/ModelSurfs.hpp @@ -11,8 +11,8 @@ namespace Components #endif private: - static std::map BufferMap; - static std::map AllocMap; + static std::unordered_map BufferMap; + static std::unordered_map AllocMap; static void ReleaseModelSurf(Game::XAssetHeader header); diff --git a/src/Components/Modules/MusicalTalent.cpp b/src/Components/Modules/MusicalTalent.cpp index e240363a..e1da9e59 100644 --- a/src/Components/Modules/MusicalTalent.cpp +++ b/src/Components/Modules/MusicalTalent.cpp @@ -2,7 +2,7 @@ namespace Components { - std::map MusicalTalent::SoundAliasList; + std::unordered_map MusicalTalent::SoundAliasList; void MusicalTalent::Replace(std::string sound, const char* file) { diff --git a/src/Components/Modules/MusicalTalent.hpp b/src/Components/Modules/MusicalTalent.hpp index 0f59a99d..5122502c 100644 --- a/src/Components/Modules/MusicalTalent.hpp +++ b/src/Components/Modules/MusicalTalent.hpp @@ -13,7 +13,7 @@ namespace Components static void Replace(std::string sound, const char* file); private: - static std::map SoundAliasList; + static std::unordered_map SoundAliasList; static Game::XAssetHeader ModifyAliases(Game::XAssetType type, std::string filename); }; } diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index f1a457e7..c27e10a8 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -4,7 +4,7 @@ namespace Components { std::string Playlist::CurrentPlaylistBuffer; std::string Playlist::ReceivedPlaylistBuffer; - std::map Playlist::MapRelocation; + std::unordered_map Playlist::MapRelocation; void Playlist::LoadPlaylist() { diff --git a/src/Components/Modules/Playlist.hpp b/src/Components/Modules/Playlist.hpp index 749cd1c3..fe76a986 100644 --- a/src/Components/Modules/Playlist.hpp +++ b/src/Components/Modules/Playlist.hpp @@ -18,7 +18,7 @@ namespace Components private: static std::string CurrentPlaylistBuffer; - static std::map MapRelocation; + static std::unordered_map MapRelocation; static DWORD StorePlaylistStub(const char** buffer); diff --git a/src/Components/Modules/StringTable.cpp b/src/Components/Modules/StringTable.cpp index 887b507f..07cdee5e 100644 --- a/src/Components/Modules/StringTable.cpp +++ b/src/Components/Modules/StringTable.cpp @@ -3,7 +3,7 @@ namespace Components { Utils::Memory::Allocator StringTable::MemAllocator; - std::map StringTable::StringTableMap; + std::unordered_map StringTable::StringTableMap; int StringTable::Hash(const char* data) { diff --git a/src/Components/Modules/StringTable.hpp b/src/Components/Modules/StringTable.hpp index 0fb846ca..ad42762b 100644 --- a/src/Components/Modules/StringTable.hpp +++ b/src/Components/Modules/StringTable.hpp @@ -12,7 +12,7 @@ namespace Components private: static Utils::Memory::Allocator MemAllocator; - static std::map StringTableMap; + static std::unordered_map StringTableMap; static int Hash(const char* data); static Game::StringTable* LoadObject(std::string filename); diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index eecd2b2a..16039a09 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -3,7 +3,7 @@ namespace Components { UIFeeder::Container UIFeeder::Current; - std::map UIFeeder::Feeders; + std::unordered_map UIFeeder::Feeders; void UIFeeder::Add(float feeder, UIFeeder::GetItemCount_t itemCountCb, UIFeeder::GetItemText_t itemTextCb, UIFeeder::Select_t selectCb) { diff --git a/src/Components/Modules/UIFeeder.hpp b/src/Components/Modules/UIFeeder.hpp index fd850df2..6a865bba 100644 --- a/src/Components/Modules/UIFeeder.hpp +++ b/src/Components/Modules/UIFeeder.hpp @@ -49,7 +49,7 @@ namespace Components static void HandleKeyStub(); static void PlaySoundStub(); - static std::map Feeders; + static std::unordered_map Feeders; static void ApplyMapFeeder(Game::dvar_t* dvar, int num); }; diff --git a/src/Components/Modules/UIScript.cpp b/src/Components/Modules/UIScript.cpp index ede668f1..d8993fe8 100644 --- a/src/Components/Modules/UIScript.cpp +++ b/src/Components/Modules/UIScript.cpp @@ -2,8 +2,8 @@ namespace Components { - std::map> UIScript::UIScripts; - std::map> UIScript::UIOwnerDraws; + std::unordered_map> UIScript::UIScripts; + std::unordered_map> UIScript::UIOwnerDraws; template<> int UIScript::Token::get() { diff --git a/src/Components/Modules/UIScript.hpp b/src/Components/Modules/UIScript.hpp index c768ce64..bad88749 100644 --- a/src/Components/Modules/UIScript.hpp +++ b/src/Components/Modules/UIScript.hpp @@ -39,7 +39,7 @@ namespace Components static bool RunMenuScript(const char* name, const char** args); static void RunMenuScriptStub(); - static std::map> UIScripts; - static std::map> UIOwnerDraws; + static std::unordered_map> UIScripts; + static std::unordered_map> UIOwnerDraws; }; } diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 64976641..1522359d 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -38,6 +38,7 @@ //#include #include #include +#include // Experimental C++17 features #include