From 2f2f5e6efa4ad640e0953c02589617d2eb99e311 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 23 Mar 2012 09:45:35 -0700 Subject: [PATCH] Code cleanup --- Library/MeterWindow.cpp | 16 ++++++++-------- Library/System.cpp | 11 ++++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 0893f5ec..6d73a42d 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1727,7 +1727,7 @@ void CMeterWindow::ScreenToWindow() screenx = monitors[m_WindowXScreen-1].screen.left; screenw = monitors[m_WindowXScreen-1].screen.right - monitors[m_WindowXScreen-1].screen.left; } - if (m_WindowXFromRight == true) + if (m_WindowXFromRight) { pixel = (screenx + screenw) - m_ScreenX; pixel -= m_AnchorScreenX; @@ -1737,7 +1737,7 @@ void CMeterWindow::ScreenToWindow() pixel = m_ScreenX - screenx; pixel += m_AnchorScreenX; } - if (m_WindowXPercentage == true) + if (m_WindowXPercentage) { num = 100.0f * (float)pixel / (float)screenw; _snwprintf_s(buffer, _TRUNCATE, L"%.5f%%", num); @@ -1746,11 +1746,11 @@ void CMeterWindow::ScreenToWindow() { _itow_s(pixel, buffer, 10); } - if (m_WindowXFromRight == true) + if (m_WindowXFromRight) { _snwprintf_s(buffer, _TRUNCATE, L"%sR", buffer); } - if (m_WindowXScreenDefined == true) + if (m_WindowXScreenDefined) { _snwprintf_s(buffer, _TRUNCATE, L"%s@%i", buffer, m_WindowXScreen); } @@ -1768,7 +1768,7 @@ void CMeterWindow::ScreenToWindow() screeny = monitors[m_WindowYScreen-1].screen.top; screenh = monitors[m_WindowYScreen-1].screen.bottom - monitors[m_WindowYScreen-1].screen.top; } - if (m_WindowYFromBottom == true) + if (m_WindowYFromBottom) { pixel = (screeny + screenh) - m_ScreenY; pixel -= m_AnchorScreenY; @@ -1778,7 +1778,7 @@ void CMeterWindow::ScreenToWindow() pixel = m_ScreenY - screeny; pixel += m_AnchorScreenY; } - if (m_WindowYPercentage == true) + if (m_WindowYPercentage) { num = 100.0f * (float)pixel / (float)screenh; _snwprintf_s(buffer, _TRUNCATE, L"%.5f%%", num); @@ -1787,11 +1787,11 @@ void CMeterWindow::ScreenToWindow() { _itow_s(pixel, buffer, 10); } - if (m_WindowYFromBottom == true) + if (m_WindowYFromBottom) { _snwprintf_s(buffer, _TRUNCATE, L"%sB", buffer); } - if (m_WindowYScreenDefined == true) + if (m_WindowYScreenDefined) { _snwprintf_s(buffer, _TRUNCATE, L"%s@%i", buffer, m_WindowYScreen); } diff --git a/Library/System.cpp b/Library/System.cpp index fe3bf6dc..bd2cc453 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -108,9 +108,9 @@ void CSystem::Initialize(HINSTANCE instance) c_Monitors.monitors.reserve(4); SetMultiMonitorInfo(); - WCHAR directory[MAX_PATH] = {0}; - GetCurrentDirectory(MAX_PATH, directory); - c_WorkingDirectory = directory; + WCHAR directory[MAX_PATH]; + DWORD len = GetCurrentDirectory(MAX_PATH, directory); + c_WorkingDirectory.assign(directory, len <= MAX_PATH ? len : 0); c_WinEventHook = SetWinEventHook( EVENT_SYSTEM_FOREGROUND, @@ -1113,9 +1113,10 @@ void CSystem::ResetWorkingDirectory() WCHAR directory[MAX_PATH] = {0}; GetCurrentDirectory(MAX_PATH, directory); - if (_wcsicmp(directory, c_WorkingDirectory.c_str()) != 0) + const WCHAR* workDir = c_WorkingDirectory.c_str(); + if (_wcsicmp(directory, workDir) != 0) { - SetCurrentDirectory(c_WorkingDirectory.c_str()); + SetCurrentDirectory(workDir); } }