From b32a962897bd3dfeb012d971a0c3349c8d58c7fd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 29 May 2019 15:50:47 +0200 Subject: tdf#125372 writer, file with lots of hints very slow to open, part6 Takes load time from 2m11 to 1m45 Since we're only interested in hints with end <= nIdx, GetLastPosSortedByEnd to avoid scanning some of the list Change-Id: Ibd80cb247176419aac5b6956593e5b7807c23cbf Reviewed-on: https://gerrit.libreoffice.org/73194 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/txtnode/ndtxt.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4a8ee16f7503..691c20f6490b 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1615,17 +1615,17 @@ bool SwTextNode::DontExpandFormat( const SwIndex& rIdx, bool bFlag, if ( HasHints() ) { m_pSwpHints->SortIfNeedBe(); - const size_t nEndCnt = m_pSwpHints->Count(); - size_t nPos = nEndCnt; - while( nPos ) + int nPos = m_pSwpHints->GetLastPosSortedByEnd(nIdx); + for ( ; nPos >= 0; --nPos) { - SwTextAttr *pTmp = m_pSwpHints->GetSortedByEnd( --nPos ); + SwTextAttr *pTmp = m_pSwpHints->GetSortedByEnd( nPos ); const sal_Int32 *pEnd = pTmp->GetEnd(); - if( !pEnd || *pEnd > nIdx ) + if( !pEnd ) continue; + assert( *pEnd <= nIdx ); if( nIdx != *pEnd ) - nPos = 0; - else if( bFlag != pTmp->DontExpand() && !pTmp->IsLockExpandFlag() + break; + if( bFlag != pTmp->DontExpand() && !pTmp->IsLockExpandFlag() && *pEnd > pTmp->GetStart()) { bRet = true; -- cgit v1.2.3