From 3b0f8ece47f70f53b1462c824463c453b47c3020 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Wed, 7 Jun 2017 23:07:19 +1000 Subject: tdf#43157 - salhelper: timer.cxx change OSL_ASSERT to assert There are a number of instances where OSL_ASSERT are just not necessary. Also, we need to change from testing if something is/is not equal to nullptr and just use the simpler form. Change-Id: I7e0b7deb12f0189030f66dd14ab23287341c82b7 Reviewed-on: https://gerrit.libreoffice.org/38507 Tested-by: Jenkins Reviewed-by: Chris Sherlock --- salhelper/source/timer.cxx | 55 +++++++++------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) (limited to 'salhelper/source') diff --git a/salhelper/source/timer.cxx b/salhelper/source/timer.cxx index 3757ea9a2cdc..435ea0a1f7e2 100644 --- a/salhelper/source/timer.cxx +++ b/salhelper/source/timer.cxx @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -106,12 +105,8 @@ void Timer::start() TimerManager *pManager = TimerManager::getTimerManager(); - OSL_ASSERT(pManager); - - if (pManager != nullptr) - { + if (pManager) pManager->registerTimer(this); - } } } @@ -119,25 +114,18 @@ void Timer::stop() { TimerManager *pManager = TimerManager::getTimerManager(); - OSL_ASSERT(pManager); - - if (pManager != nullptr) - { + if (pManager) pManager->unregisterTimer(this); - } } sal_Bool Timer::isTicking() const { TimerManager *pManager = TimerManager::getTimerManager(); - OSL_ASSERT(pManager); - if (pManager) return pManager->lookupTimer(this); else return false; - } sal_Bool Timer::isExpired() const @@ -151,16 +139,10 @@ sal_Bool Timer::isExpired() const sal_Bool Timer::expiresBefore(const Timer* pTimer) const { - OSL_ASSERT(pTimer); - - if (pTimer != nullptr) - { + if (pTimer) return m_aExpired < pTimer->m_aExpired; - } else - { return false; - } } void Timer::setAbsoluteTime(const TTimeValue& Time) @@ -242,12 +224,10 @@ TimerManager::TimerManager() { osl::MutexGuard Guard(theTimerManagerMutex::get()); - OSL_ASSERT(m_pManager == nullptr); + assert(m_pManager == nullptr); m_pManager = this; - m_pHead= nullptr; - m_notEmpty.reset(); // start thread @@ -258,7 +238,7 @@ TimerManager::~TimerManager() { osl::MutexGuard Guard(theTimerManagerMutex::get()); - if ( m_pManager == this ) + if (m_pManager == this) m_pManager = nullptr; } @@ -279,12 +259,8 @@ TimerManager* TimerManager::getTimerManager() void TimerManager::registerTimer(Timer* pTimer) { - OSL_ASSERT(pTimer); - - if ( pTimer == nullptr ) - { + if (!pTimer) return; - } osl::MutexGuard Guard(m_Lock); @@ -318,12 +294,8 @@ void TimerManager::registerTimer(Timer* pTimer) void TimerManager::unregisterTimer(Timer* pTimer) { - OSL_ASSERT(pTimer); - - if ( pTimer == nullptr ) - { + if (!pTimer) return; - } // lock access osl::MutexGuard Guard(m_Lock); @@ -344,12 +316,8 @@ void TimerManager::unregisterTimer(Timer* pTimer) bool TimerManager::lookupTimer(const Timer* pTimer) { - OSL_ASSERT(pTimer); - - if ( pTimer == nullptr ) - { + if (!pTimer) return false; - } // lock access osl::MutexGuard Guard(m_Lock); @@ -358,9 +326,7 @@ bool TimerManager::lookupTimer(const Timer* pTimer) for (Timer* pIter = m_pHead; pIter != nullptr; pIter= pIter->m_pNext) { if (pIter == pTimer) - { return true; - } } return false; @@ -368,10 +334,9 @@ bool TimerManager::lookupTimer(const Timer* pTimer) void TimerManager::checkForTimeout() { - m_Lock.acquire(); - if ( m_pHead == nullptr ) + if (!m_pHead) { m_Lock.release(); return; @@ -391,7 +356,7 @@ void TimerManager::checkForTimeout() pTimer->onShot(); // restart timer if specified - if ( ! pTimer->m_aRepeatDelta.isEmpty() ) + if (!pTimer->m_aRepeatDelta.isEmpty()) { TTimeValue Now; -- cgit