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:
parent
84c91cb1ba
commit
a2316446ca
@ -27,7 +27,7 @@ extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
stdext::hash_map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables;
|
||||
std::unordered_map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables;
|
||||
|
||||
/*
|
||||
** CConfigParser
|
||||
@ -146,7 +146,7 @@ void CConfigParser::ReadVariables()
|
||||
** \param strVariable
|
||||
** \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());
|
||||
|
||||
@ -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<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())
|
||||
{
|
||||
// Built-in variable found
|
||||
@ -698,7 +698,7 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
||||
|
||||
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())
|
||||
{
|
||||
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<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())
|
||||
{
|
||||
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"::";
|
||||
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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
return (*iter).second;
|
||||
|
@ -22,10 +22,9 @@
|
||||
#pragma warning(disable: 4503)
|
||||
|
||||
#include <windows.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hash_map>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <gdiplus.h>
|
||||
#include "ccalc-0.5.1/mparser.h"
|
||||
@ -99,7 +98,7 @@ private:
|
||||
|
||||
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 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<std::wstring, CMeasure*> m_Measures;
|
||||
std::unordered_map<std::wstring, CMeasure*> m_Measures;
|
||||
|
||||
std::vector<std::wstring> m_StyleTemplate;
|
||||
|
||||
@ -118,13 +117,13 @@ private:
|
||||
bool m_LastDefaultUsed;
|
||||
|
||||
std::vector<std::wstring> m_Sections; // The sections must be an ordered array
|
||||
stdext::hash_map<std::wstring, std::vector<std::wstring> > m_Keys;
|
||||
stdext::hash_map<std::wstring, std::wstring> m_Values;
|
||||
std::unordered_map<std::wstring, std::vector<std::wstring> > m_Keys;
|
||||
std::unordered_map<std::wstring, std::wstring> m_Values;
|
||||
|
||||
stdext::hash_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_BuiltInVariables; // Built-in 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
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define __GROUP_H__
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
class CGroup
|
||||
{
|
||||
@ -36,7 +36,7 @@ protected:
|
||||
private:
|
||||
std::wstring CreateGroup(const std::wstring& str);
|
||||
|
||||
std::set<std::wstring> m_Groups;
|
||||
std::unordered_set<std::wstring> m_Groups;
|
||||
std::wstring m_OldGroups;
|
||||
|
||||
};
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
std::map<std::wstring, Gdiplus::FontFamily*> CMeterString::c_FontFamilies;
|
||||
std::map<std::wstring, Gdiplus::Font*> CMeterString::c_Fonts;
|
||||
std::unordered_map<std::wstring, Gdiplus::FontFamily*> CMeterString::c_FontFamilies;
|
||||
std::unordered_map<std::wstring, Gdiplus::Font*> 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<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())
|
||||
{
|
||||
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<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())
|
||||
{
|
||||
m_Font = (*iter2).second;
|
||||
@ -720,7 +720,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection)
|
||||
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())
|
||||
{
|
||||
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<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())
|
||||
{
|
||||
if (collection == NULL || wcsncmp((*iter).first.c_str(), prefix.c_str(), prefix.length()) == 0)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "Meter.h"
|
||||
#include "Measure.h"
|
||||
#include <unordered_map>
|
||||
|
||||
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<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::FontFamily*> c_FontFamilies; // Cache for the font families
|
||||
static std::unordered_map<std::wstring, Gdiplus::Font*> c_Fonts; // Cache for the fonts
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -45,9 +45,9 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hash_map>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <cstdlib>
|
||||
|
Loading…
Reference in New Issue
Block a user