1
0
mirror of https://github.com/chibicitiberiu/rainmeter-studio.git synced 2024-02-24 04:33:31 +00:00

Switched map/hash_map/set for caching to unordered_map/unordered_set.

This commit is contained in:
spx 2011-02-18 16:26:58 +00:00
parent 84c91cb1ba
commit a2316446ca
6 changed files with 28 additions and 28 deletions

@ -27,7 +27,7 @@ extern CRainmeter* Rainmeter;
using namespace Gdiplus; using namespace Gdiplus;
stdext::hash_map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables; std::unordered_map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables;
/* /*
** CConfigParser ** CConfigParser
@ -146,7 +146,7 @@ void CConfigParser::ReadVariables()
** \param strVariable ** \param strVariable
** \param strValue ** \param strValue
*/ */
void CConfigParser::SetVariable(stdext::hash_map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue) void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>& 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()); // 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); std::wstring strTmp = StrToLower(strVariable);
// #1: Built-in variables // #1: Built-in variables
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp); std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
if (iter != m_BuiltInVariables.end()) if (iter != m_BuiltInVariables.end())
{ {
// Built-in variable found // Built-in variable found
@ -698,7 +698,7 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
CMeasure* CConfigParser::GetMeasure(const std::wstring& name) CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
{ {
std::map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToLower(name)); std::unordered_map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToLower(name));
if (iter != m_Measures.end()) if (iter != m_Measures.end())
{ {
return (*iter).second; return (*iter).second;
@ -1196,7 +1196,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
std::wstring strTmpSection = StrToLower(strSection); std::wstring strTmpSection = StrToLower(strSection);
std::wstring strTmpKey = StrToLower(strKey); std::wstring strTmpKey = StrToLower(strKey);
stdext::hash_map<std::wstring, std::vector<std::wstring> >::iterator iter = m_Keys.find(strTmpSection); std::unordered_map<std::wstring, std::vector<std::wstring> >::iterator iter = m_Keys.find(strTmpSection);
if (iter != m_Keys.end()) if (iter != m_Keys.end())
{ {
std::vector<std::wstring>& array = (*iter).second; std::vector<std::wstring>& array = (*iter).second;
@ -1222,7 +1222,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
std::wstring strTmp = strSection + L"::"; std::wstring strTmp = strSection + L"::";
strTmp += strKey; strTmp += strKey;
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLower(strTmp)); std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLower(strTmp));
if (iter != m_Values.end()) if (iter != m_Values.end())
{ {
return (*iter).second; return (*iter).second;
@ -1240,7 +1240,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
*/ */
std::vector<std::wstring> CConfigParser::GetKeys(const std::wstring& strSection) std::vector<std::wstring> CConfigParser::GetKeys(const std::wstring& strSection)
{ {
stdext::hash_map<std::wstring, std::vector<std::wstring> >::const_iterator iter = m_Keys.find(StrToLower(strSection)); std::unordered_map<std::wstring, std::vector<std::wstring> >::const_iterator iter = m_Keys.find(StrToLower(strSection));
if (iter != m_Keys.end()) if (iter != m_Keys.end())
{ {
return (*iter).second; return (*iter).second;

@ -22,10 +22,9 @@
#pragma warning(disable: 4503) #pragma warning(disable: 4503)
#include <windows.h> #include <windows.h>
#include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <hash_map> #include <unordered_map>
#include <algorithm> #include <algorithm>
#include <gdiplus.h> #include <gdiplus.h>
#include "ccalc-0.5.1/mparser.h" #include "ccalc-0.5.1/mparser.h"
@ -99,7 +98,7 @@ private:
void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow); void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow);
static void SetVariable(stdext::hash_map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue); static void SetVariable(std::unordered_map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue);
static void SetMultiMonitorVariables(bool reset); static void SetMultiMonitorVariables(bool reset);
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); } 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; std::wstring m_Filename;
hqMathParser* m_Parser; hqMathParser* m_Parser;
std::map<std::wstring, CMeasure*> m_Measures; std::unordered_map<std::wstring, CMeasure*> m_Measures;
std::vector<std::wstring> m_StyleTemplate; std::vector<std::wstring> m_StyleTemplate;
@ -118,13 +117,13 @@ private:
bool m_LastDefaultUsed; bool m_LastDefaultUsed;
std::vector<std::wstring> m_Sections; // The sections must be an ordered array std::vector<std::wstring> m_Sections; // The sections must be an ordered array
stdext::hash_map<std::wstring, std::vector<std::wstring> > m_Keys; std::unordered_map<std::wstring, std::vector<std::wstring> > m_Keys;
stdext::hash_map<std::wstring, std::wstring> m_Values; std::unordered_map<std::wstring, std::wstring> m_Values;
stdext::hash_map<std::wstring, std::wstring> m_BuiltInVariables; // Built-in variables std::unordered_map<std::wstring, std::wstring> m_BuiltInVariables; // Built-in variables
stdext::hash_map<std::wstring, std::wstring> m_Variables; // User-defined variables std::unordered_map<std::wstring, std::wstring> m_Variables; // User-defined variables
static stdext::hash_map<std::wstring, std::wstring> c_MonitorVariables; // Monitor variables static std::unordered_map<std::wstring, std::wstring> c_MonitorVariables; // Monitor variables
}; };
#endif #endif

@ -20,7 +20,7 @@
#define __GROUP_H__ #define __GROUP_H__
#include <string> #include <string>
#include <set> #include <unordered_set>
class CGroup class CGroup
{ {
@ -36,7 +36,7 @@ protected:
private: private:
std::wstring CreateGroup(const std::wstring& str); std::wstring CreateGroup(const std::wstring& str);
std::set<std::wstring> m_Groups; std::unordered_set<std::wstring> m_Groups;
std::wstring m_OldGroups; std::wstring m_OldGroups;
}; };

@ -24,8 +24,8 @@
using namespace Gdiplus; using namespace Gdiplus;
std::map<std::wstring, Gdiplus::FontFamily*> CMeterString::c_FontFamilies; std::unordered_map<std::wstring, Gdiplus::FontFamily*> CMeterString::c_FontFamilies;
std::map<std::wstring, Gdiplus::Font*> CMeterString::c_Fonts; std::unordered_map<std::wstring, Gdiplus::Font*> CMeterString::c_Fonts;
void StringToUpper(std::wstring& str) void StringToUpper(std::wstring& str)
{ {
@ -142,7 +142,7 @@ void CMeterString::Initialize()
// Check if the font family is in the cache and use it // Check if the font family is in the cache and use it
std::wstring cacheKey; std::wstring cacheKey;
std::wstring systemFontFaceKey = FontFaceToString(m_FontFace, NULL); std::wstring systemFontFaceKey = FontFaceToString(m_FontFace, NULL);
std::map<std::wstring, Gdiplus::FontFamily*>::const_iterator iter = c_FontFamilies.find(systemFontFaceKey); std::unordered_map<std::wstring, Gdiplus::FontFamily*>::const_iterator iter = c_FontFamilies.find(systemFontFaceKey);
if (iter != c_FontFamilies.end()) if (iter != c_FontFamilies.end())
{ {
m_FontFamily = (*iter).second; m_FontFamily = (*iter).second;
@ -246,7 +246,7 @@ void CMeterString::Initialize()
// Check if the font is in the cache and use it // Check if the font is in the cache and use it
cacheKey += L"-"; cacheKey += L"-";
cacheKey += FontPropertiesToString(size, style); cacheKey += FontPropertiesToString(size, style);
std::map<std::wstring, Gdiplus::Font*>::const_iterator iter2 = c_Fonts.find(cacheKey); std::unordered_map<std::wstring, Gdiplus::Font*>::const_iterator iter2 = c_Fonts.find(cacheKey);
if (iter2 != c_Fonts.end()) if (iter2 != c_Fonts.end())
{ {
m_Font = (*iter2).second; m_Font = (*iter2).second;
@ -720,7 +720,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection)
StringToLower(prefix); StringToLower(prefix);
} }
std::map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin(); std::unordered_map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
while (iter2 != c_Fonts.end()) while (iter2 != c_Fonts.end())
{ {
if (collection == NULL || wcsncmp((*iter2).first.c_str(), prefix.c_str(), prefix.length()) == 0) 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(); if (collection == NULL) c_Fonts.clear();
std::map<std::wstring, Gdiplus::FontFamily*>::iterator iter = c_FontFamilies.begin(); std::unordered_map<std::wstring, Gdiplus::FontFamily*>::iterator iter = c_FontFamilies.begin();
while (iter != c_FontFamilies.end()) while (iter != c_FontFamilies.end())
{ {
if (collection == NULL || wcsncmp((*iter).first.c_str(), prefix.c_str(), prefix.length()) == 0) if (collection == NULL || wcsncmp((*iter).first.c_str(), prefix.c_str(), prefix.length()) == 0)

@ -21,6 +21,7 @@
#include "Meter.h" #include "Meter.h"
#include "Measure.h" #include "Measure.h"
#include <unordered_map>
namespace Gdiplus namespace Gdiplus
{ {
@ -103,8 +104,8 @@ private:
static std::wstring FontFaceToString(const std::wstring& fontFace, Gdiplus::PrivateFontCollection* collection); static std::wstring FontFaceToString(const std::wstring& fontFace, Gdiplus::PrivateFontCollection* collection);
static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style); static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style);
static std::map<std::wstring, Gdiplus::FontFamily*> c_FontFamilies; // Cache for the font families static std::unordered_map<std::wstring, Gdiplus::FontFamily*> c_FontFamilies; // Cache for the font families
static std::map<std::wstring, Gdiplus::Font*> c_Fonts; // Cache for the fonts static std::unordered_map<std::wstring, Gdiplus::Font*> c_Fonts; // Cache for the fonts
}; };
#endif #endif

@ -45,9 +45,9 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <hash_map> #include <unordered_map>
#include <unordered_set>
#include <list> #include <list>
#include <set>
#include <sstream> #include <sstream>
#include <ctime> #include <ctime>
#include <cstdlib> #include <cstdlib>