From 34005f14a4510915f5bd1a4242081b1029824a8f Mon Sep 17 00:00:00 2001 From: spx Date: Sun, 27 Nov 2011 08:30:39 +0000 Subject: [PATCH] Switched from std::wstring.compare() to wcscmp(). --- Library/MeasureCalc.cpp | 7 ++++--- Library/MeasureScript.cpp | 2 +- Library/Meter.cpp | 9 +++++---- Library/MeterBar.cpp | 2 +- Library/MeterBitmap.cpp | 2 +- Library/MeterButton.cpp | 2 +- Library/MeterHistogram.cpp | 6 +++--- Library/MeterImage.cpp | 2 +- Library/MeterRotator.cpp | 2 +- Library/MeterString.cpp | 2 +- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 5cb0907b..2d19e513 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -143,7 +143,7 @@ void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section) m_UpdateRandom = 0!=parser.ReadInt(section, L"UpdateRandom", 0); if (!m_Initialized || - m_FormulaHolder != m_Formula || + wcscmp(m_FormulaHolder.c_str(), m_Formula.c_str()) != 0 || oldLowBound != m_LowBound || oldHighBound != m_HighBound || oldUpdateRandom != m_UpdateRandom) @@ -183,9 +183,10 @@ void CMeasureCalc::FormulaReplace() WCHAR buffer[32]; _itow_s(randNumber, buffer, 10); + size_t len = wcslen(buffer); - m_Formula.replace(loc, 6, buffer); - loc += wcslen(buffer); + m_Formula.replace(loc, 6, buffer, len); + loc += len; } else { diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index bb470459..23d4ca53 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -141,7 +141,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section) std::string scriptFile = ConvertToAscii(m_MeterWindow->MakePathAbsolute(file).c_str()); if (!m_Initialized || - scriptFile != m_ScriptFile) + strcmp(scriptFile.c_str(), m_ScriptFile.c_str()) != 0) { DeleteLuaScript(); diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 925e8d95..cfa24be9 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -282,11 +282,10 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section) std::wstring oldStyleX = m_StyleX; std::wstring oldStyleY = m_StyleY; - std::wstring oldStyleHidden = m_StyleHidden; std::wstring coord = parser.ReadString(section, L"X", L"0"); m_StyleX = parser.GetLastUsedStyle(); - if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && m_StyleX != oldStyleX) + if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleX.c_str(), oldStyleX.c_str()) != 0) { if (!coord.empty()) { @@ -325,7 +324,7 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section) coord = parser.ReadString(section, L"Y", L"0"); m_StyleY = parser.GetLastUsedStyle(); - if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && m_StyleY != oldStyleY) + if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleY.c_str(), oldStyleY.c_str()) != 0) { if (!coord.empty()) { @@ -376,9 +375,11 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { + std::wstring oldStyleHidden = m_StyleHidden; + const std::wstring& result = parser.ReadString(section, L"Hidden", L"0"); m_StyleHidden = parser.GetLastUsedStyle(); - if (parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && m_StyleHidden != oldStyleHidden) + if (parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleHidden.c_str(), oldStyleHidden.c_str()) != 0) { m_Hidden = 0!=parser.ParseInt(result.c_str(), 0); } diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index 62cfc647..3b6f99e9 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -140,7 +140,7 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_Initialized) { - m_NeedsReload = (oldImageName != m_ImageName); + m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsConfigsChanged()) diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index bd1b66de..f79e26cb 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -221,7 +221,7 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_Initialized) { - m_NeedsReload = (oldImageName != m_ImageName); + m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsConfigsChanged()) diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index 9ded9e2f..84cf71d5 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -161,7 +161,7 @@ void CMeterButton::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_Initialized) { - m_NeedsReload = (oldImageName != m_ImageName); + m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsConfigsChanged()) diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index a0798145..fd16d92a 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -273,9 +273,9 @@ void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section) m_W = oldW; m_H = oldH; - m_PrimaryNeedsReload = (oldPrimaryImageName != m_PrimaryImageName); - m_SecondaryNeedsReload = (oldSecondaryImageName != m_SecondaryImageName); - m_BothNeedsReload = (oldBothImageName != m_BothImageName); + m_PrimaryNeedsReload = (wcscmp(oldPrimaryImageName.c_str(), m_PrimaryImageName.c_str()) != 0); + m_SecondaryNeedsReload = (wcscmp(oldSecondaryImageName.c_str(), m_SecondaryImageName.c_str()) != 0); + m_BothNeedsReload = (wcscmp(oldBothImageName.c_str(), m_BothImageName.c_str()) != 0); if (m_PrimaryNeedsReload || m_SecondaryNeedsReload || diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index 9012d04a..7f5d79fa 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -210,7 +210,7 @@ bool CMeterImage::Update() m_ImageNameResult = m_MeterWindow->MakePathAbsolute(m_ImageNameResult); } - LoadImage(m_ImageNameResult, oldResult != m_ImageNameResult); + LoadImage(m_ImageNameResult, (wcscmp(oldResult.c_str(), m_ImageNameResult.c_str()) != 0)); return true; } else if (m_NeedsRedraw) diff --git a/Library/MeterRotator.cpp b/Library/MeterRotator.cpp index 14546a96..2f8524ce 100644 --- a/Library/MeterRotator.cpp +++ b/Library/MeterRotator.cpp @@ -115,7 +115,7 @@ void CMeterRotator::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_Initialized) { - m_NeedsReload = (oldImageName != m_ImageName); + m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsConfigsChanged()) diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 95b1db03..ed71e1f8 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -463,7 +463,7 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section) } if (m_Initialized && - (oldFontFace != m_FontFace || + (wcscmp(oldFontFace.c_str(), m_FontFace.c_str()) != 0 || oldFontSize != m_FontSize || oldStyle != m_Style)) {