summaryrefslogtreecommitdiff
path: root/sw/source/core/bastyp/swcache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/bastyp/swcache.cxx')
-rw-r--r--sw/source/core/bastyp/swcache.cxx40
1 files changed, 17 insertions, 23 deletions
diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx
index fee19de3e583..531ce2de4449 100644
--- a/sw/source/core/bastyp/swcache.cxx
+++ b/sw/source/core/bastyp/swcache.cxx
@@ -22,6 +22,7 @@
#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
+#include <utility>
#include <limits.h>
@@ -43,20 +44,19 @@ void SwCache::Check()
SwCacheObj *const pOldRealFirst = m_pRealFirst;
while ( pObj )
{
- // the object must be found also when moving backwards
- SwCacheObj *pTmp = m_pLast;
- while ( pTmp && pTmp != pObj )
- pTmp = pTmp->GetPrev();
- assert(pTmp && "Object not found.");
-
++nCnt;
if ( pObj == m_pFirst )
bFirstFound = true;
- if ( !pObj->GetNext() )
+ SwCacheObj* pNext = pObj->GetNext();
+ if ( !pNext )
{
assert(pObj == m_pLast);
}
- pObj = pObj->GetNext();
+ else
+ {
+ assert(pObj == pNext->GetPrev());
+ }
+ pObj = pNext;
assert(pObj != pOldRealFirst); (void) pOldRealFirst;
}
assert(bFirstFound);
@@ -76,16 +76,15 @@ void SwCache::Check()
SwCache::SwCache( const sal_uInt16 nInitSize
#ifdef DBG_UTIL
- , const OString &rNm
+ , OString aNm
#endif
) :
- m_aCacheObjects(),
m_pRealFirst( nullptr ),
m_pFirst( nullptr ),
m_pLast( nullptr ),
m_nCurMax( nInitSize )
#ifdef DBG_UTIL
- , m_aName( rNm )
+ , m_aName(std::move( aNm ))
, m_nAppend( 0 )
, m_nInsertFree( 0 )
, m_nReplace( 0 )
@@ -151,17 +150,14 @@ void SwCache::Flush()
INCREMENT( m_nFlushCnt );
SwCacheObj *pObj = m_pRealFirst;
m_pRealFirst = m_pFirst = m_pLast = nullptr;
- SwCacheObj *pTmp;
while ( pObj )
{
assert(!pObj->IsLocked());
- {
- pTmp = pObj;
- pObj = pTmp->GetNext();
- m_aFreePositions.push_back( pTmp->GetCachePos() );
- m_aCacheObjects[pTmp->GetCachePos()].reset(); // deletes pTmp
- INCREMENT( m_nFlushedObjects );
- }
+ SwCacheObj *pTmp = pObj;
+ pObj = pTmp->GetNext();
+ m_aFreePositions.push_back( pTmp->GetCachePos() );
+ m_aCacheObjects[pTmp->GetCachePos()].reset(); // deletes pTmp
+ INCREMENT( m_nFlushedObjects );
}
}
@@ -327,9 +323,7 @@ void SwCache::Delete(void const*const pOwner, sal_uInt16 const nIndex)
{
INCREMENT( m_nDelete );
if (SwCacheObj *const pObj = Get(pOwner, nIndex, false))
- {
DeleteObj(pObj);
- }
}
void SwCache::Delete( const void *pOwner )
@@ -476,13 +470,13 @@ SwCacheObj::~SwCacheObj()
#ifdef DBG_UTIL
void SwCacheObj::Lock()
{
- OSL_ENSURE( m_nLock < UCHAR_MAX, "Too many Locks for CacheObject." );
+ assert( m_nLock < UCHAR_MAX && "Too many Locks for CacheObject." );
++m_nLock;
}
void SwCacheObj::Unlock()
{
- OSL_ENSURE( m_nLock, "No more Locks available." );
+ assert( m_nLock && "No more Locks available." );
--m_nLock;
}
#endif