From 1c62ebdcd76341eaa43a2a27fa96c1fe518ce890 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Oct 2017 23:09:56 +0100 Subject: [PATCH] Minor optimizations in wxProgressDialog Don't bother performing the updates if nothing was requested. And ensure that nothing is requested even more often than it already was by not requesting an update if the new value is the same as the old one. --- src/msw/progdlg.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/msw/progdlg.cpp b/src/msw/progdlg.cpp index 3545ba0700..2ef1d5c9d4 100644 --- a/src/msw/progdlg.cpp +++ b/src/msw/progdlg.cpp @@ -459,10 +459,13 @@ bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip) { wxCriticalSectionLocker locker(m_sharedData->m_cs); - m_sharedData->m_value = value; - m_sharedData->m_notifications |= wxSPDD_VALUE_CHANGED; + if ( value != m_sharedData->m_value ) + { + m_sharedData->m_value = value; + m_sharedData->m_notifications |= wxSPDD_VALUE_CHANGED; + } - if ( !newmsg.empty() ) + if ( !newmsg.empty() && newmsg != m_message ) { m_message = newmsg; m_sharedData->m_message = newmsg; @@ -532,7 +535,7 @@ bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip) m_sharedData->m_notifications |= wxSPDD_PBMARQUEE_CHANGED; } - if ( !newmsg.empty() ) + if ( !newmsg.empty() && newmsg != m_message ) { m_message = newmsg; m_sharedData->m_message = newmsg; @@ -1197,7 +1200,9 @@ wxProgressDialogTaskRunner::TaskDialogCallbackProc break; case TDN_TIMER: - PerformNotificationUpdates(hwnd, sharedData); + // Don't perform updates if nothing needs to be done. + if ( sharedData->m_notifications ) + PerformNotificationUpdates(hwnd, sharedData); /* Decide whether we should end the dialog. This is done if either