summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-08-30 13:37:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-30 16:58:21 +0200
commitb0c5274497f252c6a41904d6249191d910c3f199 (patch)
tree1f2519b8f8dc08aae595874ae3e432ccf0da8087
parentbe7d65019566eba59ec596672d9d25b56e47f748 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/bastyp/swcache.cxx15
1 files changed, 7 insertions, 8 deletions
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);