diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-11-07 16:14:21 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-09 19:44:25 +0100 |
commit | 6a5dbe73537642b06bcde782118a34b4593d17eb (patch) | |
tree | ae6f0d75dde1ab0a8cc524edbad19338ea90ddf0 /sw | |
parent | 123e49d6e307c41a5f59878335563ad7203b23ff (diff) |
do not iterate over all bookmarks in SwTxtNode::Update()
3f9872185e introduced new API for fast finding of marks to a specific text node,
so use that (code itself based on cb46aaf2d7).
This makes mailmerge faster (since it can create a huge document, and especially
with the change to use UNO bookmarks to mark starts of MM documents inside
the larger single document there can be a large number of marks).
Change-Id: I30ec69acf423e9a62fae5f5492ed8744cb727a56
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 59793051e238..bf15ea2521c6 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1067,12 +1067,19 @@ void SwTxtNode::Update( { bool bAtLeastOneBookmarkMoved = false; bool bAtLeastOneExpandedBookmarkAtInsertionPosition = false; - const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for ( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin(); - ppMark != pMarkAccess->getAllMarksEnd(); - ++ppMark ) - { - const ::sw::mark::IMark* const pMark = ppMark->get(); + // A text node already knows its marks via its SwIndexes. + std::set<const sw::mark::IMark*> aSeenMarks; + const SwIndex* next; + for (const SwIndex* pIndex = GetFirstIndex(); pIndex; pIndex = next ) + { + next = pIndex->GetNext(); + const sw::mark::IMark* pMark = pIndex->GetMark(); + if (!pMark) + continue; + // Only handle bookmarks once, if they start and end at this node as well. + if (aSeenMarks.find(pMark) != aSeenMarks.end()) + continue; + aSeenMarks.insert(pMark); const SwPosition* pEnd = &pMark->GetMarkEnd(); SwIndex & rEndIdx = const_cast<SwIndex&>(pEnd->nContent); if( this == &pEnd->nNode.GetNode() && |