[Libreoffice-commits] core.git: salhelper/source
Chris Sherlock
chris.sherlock79 at gmail.com
Sun Jun 18 11:50:24 UTC 2017
salhelper/source/timer.cxx | 55 ++++++++-------------------------------------
1 file changed, 10 insertions(+), 45 deletions(-)
New commits:
commit 3b0f8ece47f70f53b1462c824463c453b47c3020
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Wed Jun 7 23:07:19 2017 +1000
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 <ci at libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
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 <salhelper/timer.hxx>
#include <salhelper/simplereferenceobject.hxx>
-#include <osl/diagnose.h>
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
@@ -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;
More information about the Libreoffice-commits
mailing list