From a2316446cad712a41aef4a765c3a6fac3ea2a758 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 18 Feb 2011 16:26:58 +0000 Subject: [PATCH] Switched map/hash_map/set for caching to unordered_map/unordered_set. --- Library/ConfigParser.cpp | 14 +++++++------- Library/ConfigParser.h | 17 ++++++++--------- Library/Group.h | 4 ++-- Library/MeterString.cpp | 12 ++++++------ Library/MeterString.h | 5 +++-- Library/StdAfx.h | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 3e74f32b..166885b9 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -27,7 +27,7 @@ extern CRainmeter* Rainmeter; using namespace Gdiplus; -stdext::hash_map CConfigParser::c_MonitorVariables; +std::unordered_map CConfigParser::c_MonitorVariables; /* ** CConfigParser @@ -146,7 +146,7 @@ void CConfigParser::ReadVariables() ** \param strVariable ** \param strValue */ -void CConfigParser::SetVariable(stdext::hash_map& variables, const std::wstring& strVariable, const std::wstring& strValue) +void CConfigParser::SetVariable(std::unordered_map& variables, const std::wstring& strVariable, const std::wstring& strValue) { // LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size()); @@ -165,7 +165,7 @@ bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& s std::wstring strTmp = StrToLower(strVariable); // #1: Built-in variables - stdext::hash_map::const_iterator iter = m_BuiltInVariables.find(strTmp); + std::unordered_map::const_iterator iter = m_BuiltInVariables.find(strTmp); if (iter != m_BuiltInVariables.end()) { // Built-in variable found @@ -698,7 +698,7 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure) CMeasure* CConfigParser::GetMeasure(const std::wstring& name) { - std::map::const_iterator iter = m_Measures.find(StrToLower(name)); + std::unordered_map::const_iterator iter = m_Measures.find(StrToLower(name)); if (iter != m_Measures.end()) { return (*iter).second; @@ -1196,7 +1196,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring& std::wstring strTmpSection = StrToLower(strSection); std::wstring strTmpKey = StrToLower(strKey); - stdext::hash_map >::iterator iter = m_Keys.find(strTmpSection); + std::unordered_map >::iterator iter = m_Keys.find(strTmpSection); if (iter != m_Keys.end()) { std::vector& array = (*iter).second; @@ -1222,7 +1222,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons std::wstring strTmp = strSection + L"::"; strTmp += strKey; - stdext::hash_map::const_iterator iter = m_Values.find(StrToLower(strTmp)); + std::unordered_map::const_iterator iter = m_Values.find(StrToLower(strTmp)); if (iter != m_Values.end()) { return (*iter).second; @@ -1240,7 +1240,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons */ std::vector CConfigParser::GetKeys(const std::wstring& strSection) { - stdext::hash_map >::const_iterator iter = m_Keys.find(StrToLower(strSection)); + std::unordered_map >::const_iterator iter = m_Keys.find(StrToLower(strSection)); if (iter != m_Keys.end()) { return (*iter).second; diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 7e08e62f..aa9887c5 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -22,10 +22,9 @@ #pragma warning(disable: 4503) #include -#include #include #include -#include +#include #include #include #include "ccalc-0.5.1/mparser.h" @@ -99,7 +98,7 @@ private: void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow); - static void SetVariable(stdext::hash_map& variables, const std::wstring& strVariable, const std::wstring& strValue); + static void SetVariable(std::unordered_map& variables, const std::wstring& strVariable, const std::wstring& strValue); static void SetMultiMonitorVariables(bool reset); static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); } @@ -109,7 +108,7 @@ private: std::wstring m_Filename; hqMathParser* m_Parser; - std::map m_Measures; + std::unordered_map m_Measures; std::vector m_StyleTemplate; @@ -118,13 +117,13 @@ private: bool m_LastDefaultUsed; std::vector m_Sections; // The sections must be an ordered array - stdext::hash_map > m_Keys; - stdext::hash_map m_Values; + std::unordered_map > m_Keys; + std::unordered_map m_Values; - stdext::hash_map m_BuiltInVariables; // Built-in variables - stdext::hash_map m_Variables; // User-defined variables + std::unordered_map m_BuiltInVariables; // Built-in variables + std::unordered_map m_Variables; // User-defined variables - static stdext::hash_map c_MonitorVariables; // Monitor variables + static std::unordered_map c_MonitorVariables; // Monitor variables }; #endif diff --git a/Library/Group.h b/Library/Group.h index 8f2b970a..40338f23 100644 --- a/Library/Group.h +++ b/Library/Group.h @@ -20,7 +20,7 @@ #define __GROUP_H__ #include -#include +#include class CGroup { @@ -36,7 +36,7 @@ protected: private: std::wstring CreateGroup(const std::wstring& str); - std::set m_Groups; + std::unordered_set m_Groups; std::wstring m_OldGroups; }; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 8c021c79..b0c0c144 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -24,8 +24,8 @@ using namespace Gdiplus; -std::map CMeterString::c_FontFamilies; -std::map CMeterString::c_Fonts; +std::unordered_map CMeterString::c_FontFamilies; +std::unordered_map CMeterString::c_Fonts; void StringToUpper(std::wstring& str) { @@ -142,7 +142,7 @@ void CMeterString::Initialize() // Check if the font family is in the cache and use it std::wstring cacheKey; std::wstring systemFontFaceKey = FontFaceToString(m_FontFace, NULL); - std::map::const_iterator iter = c_FontFamilies.find(systemFontFaceKey); + std::unordered_map::const_iterator iter = c_FontFamilies.find(systemFontFaceKey); if (iter != c_FontFamilies.end()) { m_FontFamily = (*iter).second; @@ -246,7 +246,7 @@ void CMeterString::Initialize() // Check if the font is in the cache and use it cacheKey += L"-"; cacheKey += FontPropertiesToString(size, style); - std::map::const_iterator iter2 = c_Fonts.find(cacheKey); + std::unordered_map::const_iterator iter2 = c_Fonts.find(cacheKey); if (iter2 != c_Fonts.end()) { m_Font = (*iter2).second; @@ -720,7 +720,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection) StringToLower(prefix); } - std::map::iterator iter2 = c_Fonts.begin(); + std::unordered_map::iterator iter2 = c_Fonts.begin(); while (iter2 != c_Fonts.end()) { if (collection == NULL || wcsncmp((*iter2).first.c_str(), prefix.c_str(), prefix.length()) == 0) @@ -738,7 +738,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection) } if (collection == NULL) c_Fonts.clear(); - std::map::iterator iter = c_FontFamilies.begin(); + std::unordered_map::iterator iter = c_FontFamilies.begin(); while (iter != c_FontFamilies.end()) { if (collection == NULL || wcsncmp((*iter).first.c_str(), prefix.c_str(), prefix.length()) == 0) diff --git a/Library/MeterString.h b/Library/MeterString.h index a424bb93..476a4309 100644 --- a/Library/MeterString.h +++ b/Library/MeterString.h @@ -21,6 +21,7 @@ #include "Meter.h" #include "Measure.h" +#include namespace Gdiplus { @@ -103,8 +104,8 @@ private: static std::wstring FontFaceToString(const std::wstring& fontFace, Gdiplus::PrivateFontCollection* collection); static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style); - static std::map c_FontFamilies; // Cache for the font families - static std::map c_Fonts; // Cache for the fonts + static std::unordered_map c_FontFamilies; // Cache for the font families + static std::unordered_map c_Fonts; // Cache for the fonts }; #endif diff --git a/Library/StdAfx.h b/Library/StdAfx.h index 722d4445..433ae65c 100644 --- a/Library/StdAfx.h +++ b/Library/StdAfx.h @@ -45,9 +45,9 @@ #include #include #include -#include +#include +#include #include -#include #include #include #include