sw/source/core/txtnode/ndtxt.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
New commits: commit ad51d8b6f691524f3c6d270419264e3d2e1201b6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 14:50:00 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 19:53:47 2024 +0200 tdf#144208 speedup doc with lots of redline (8) re-arrange the loops so that we only do the insert if we see a mark or a redline that we are actually interested in. This avoids a chunk of work when we hit the nasty nodes that have 600 marks attached to them. Change-Id: I9dae831ceaf0f09ac5a2d985a54f6690f7eef0a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168779 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index c71bdce6bfb8..e415dc3e6a0c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1454,18 +1454,16 @@ void SwTextNode::Update( SwContentNodeTmp aTmpIdxReg; if (!(eMode & UpdateMode::Negative) && !(eMode & UpdateMode::Delete)) { - std::vector<SwRangeRedline*> vMyRedlines; + o3tl::sorted_vector<SwRangeRedline*> vMyRedlines; // walk the list of SwContentIndex attached to me and see if any of them are redlines const SwContentIndex* pContentNodeIndex = GetFirstIndex(); while (pContentNodeIndex) { SwRangeRedline* pRedl = pContentNodeIndex->GetRedline(); - if (pRedl) - vMyRedlines.push_back(pRedl); + if (pRedl && (pRedl->HasMark() || this == &pRedl->GetPoint()->GetNode())) + vMyRedlines.insert(pRedl); pContentNodeIndex = pContentNodeIndex->GetNext(); } - std::sort(vMyRedlines.begin(), vMyRedlines.end()); - vMyRedlines.erase( std::unique( vMyRedlines.begin(), vMyRedlines.end() ), vMyRedlines.end() ); for (SwRangeRedline* pRedl : vMyRedlines) { if ( pRedl->HasMark() ) @@ -1511,6 +1509,12 @@ void SwTextNode::Update( const sw::mark::IMark* pMark = pIndex->GetMark(); if (!pMark) continue; + // filter out ones that cannot match to reduce the max size of aSeenMarks + const SwPosition* pMarkPos1 = &pMark->GetMarkPos(); + const SwPosition* pMarkPos2 = pMark->IsExpanded() ? &pMark->GetOtherMarkPos() : nullptr; + if (pMarkPos1->nContent.GetIndex() != rPos.GetIndex() + && (pMarkPos2 == nullptr || pMarkPos2->nContent.GetIndex() != rPos.GetIndex())) + continue; // Only handle bookmarks once, if they start and end at this node as well. if (!aSeenMarks.insert(pMark).second) continue;