sw/source/core/bastyp/swcache.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
New commits: commit b0c5274497f252c6a41904d6249191d910c3f199 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Aug 30 13:37:27 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 30 16:58:21 2022 +0200 reduce cost of SwCache::Check which makes up 10% of the CPU cost of running writer unit tests. We can achieve the same correctness testing without an O(n^2) algorithm Change-Id: I2ba0574fa63a457b3c7bd670498a0c64a35280b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139040 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx index 7f44352beab6..531ce2de4449 100644 --- a/sw/source/core/bastyp/swcache.cxx +++ b/sw/source/core/bastyp/swcache.cxx @@ -44,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);