summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-07-25 16:02:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-27 19:01:42 +0200
commitd5e922f0864b88ff44c49e75f984e96659171771 (patch)
tree1eb76f130d033892e259814a3c2cd6a03f09bd0c
parentbaf8d2c1c16cb3bdc4edad2560f95fea807a034f (diff)
tdf#119840 Store pointer to redline
in SwContentIndex, so we can walk the sw::Ring of SwContentIndex attached to a SwContentNode, which is considerably faster than scanning the redline array. Shaves 10% off load time Change-Id: I98c9815d98846862280f5a2b0a656667cf63f05d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137438 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/contentindex.hxx7
-rw-r--r--sw/inc/redline.hxx5
-rw-r--r--sw/source/core/doc/docredln.cxx12
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx17
4 files changed, 36 insertions, 5 deletions
diff --git a/sw/inc/contentindex.hxx b/sw/inc/contentindex.hxx
index c05845b378c7..0e2abc582116 100644
--- a/sw/inc/contentindex.hxx
+++ b/sw/inc/contentindex.hxx
@@ -28,6 +28,7 @@
class SwContentNode;
class SwContentIndexReg;
struct SwPosition;
+class SwRangeRedline;
namespace sw::mark { class IMark; }
@@ -43,6 +44,9 @@ private:
SwContentIndex * m_pNext;
SwContentIndex * m_pPrev;
+ /// points to the SwRangeRedline (if any) that contains this SwIndex, via SwPosition and SwPaM
+ SwRangeRedline * m_pRangeRedline = nullptr;
+
/// Pointer to a mark that owns this position to allow fast lookup of marks of an SwContentIndexReg.
const sw::mark::IMark* m_pMark;
@@ -101,6 +105,9 @@ public:
const sw::mark::IMark* GetMark() const { return m_pMark; }
void SetMark(const sw::mark::IMark* pMark);
+
+ SwRangeRedline* GetRedline() const { return m_pRangeRedline; }
+ void SetRedline(SwRangeRedline* pRangeRedline) { m_pRangeRedline = pRangeRedline; }
};
SW_DLLPUBLIC std::ostream& operator <<(std::ostream& s, const SwContentIndex& index);
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index dfbfa177a855..181001fed6b1 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -178,7 +178,10 @@ public:
bool bDelLP) :
SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
m_nId( s_nLastId++ ), m_bDelLastPara( bDelLP ), m_bIsVisible( true )
- {}
+ {
+ GetBound().nContent.SetRedline(this);
+ GetBound(false).nContent.SetRedline(this);
+ }
SwRangeRedline( const SwRangeRedline& );
virtual ~SwRangeRedline() override;
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 4a1134f0d78e..916d81c48d9b 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1110,6 +1110,9 @@ SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam )
m_pContentSect( nullptr ),
m_nId( s_nLastId++ )
{
+ GetBound().nContent.SetRedline(this);
+ GetBound(false).nContent.SetRedline(this);
+
m_bDelLastPara = false;
m_bIsVisible = true;
if( !rPam.HasMark() )
@@ -1130,6 +1133,9 @@ SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam )
m_pContentSect( nullptr ),
m_nId( s_nLastId++ )
{
+ GetBound().nContent.SetRedline(this);
+ GetBound(false).nContent.SetRedline(this);
+
m_bDelLastPara = false;
m_bIsVisible = true;
if( !rPam.HasMark() )
@@ -1142,6 +1148,9 @@ SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPosition& rP
m_pContentSect( nullptr ),
m_nId( s_nLastId++ )
{
+ GetBound().nContent.SetRedline(this);
+ GetBound(false).nContent.SetRedline(this);
+
m_bDelLastPara = false;
m_bIsVisible = true;
}
@@ -1152,6 +1161,9 @@ SwRangeRedline::SwRangeRedline( const SwRangeRedline& rCpy )
m_pContentSect( nullptr ),
m_nId( s_nLastId++ )
{
+ GetBound().nContent.SetRedline(this);
+ GetBound(false).nContent.SetRedline(this);
+
m_bDelLastPara = false;
m_bIsVisible = true;
if( !rCpy.HasMark() )
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 88465dbded6f..6ae44f14b040 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1410,11 +1410,20 @@ void SwTextNode::Update(
SwContentNodeTmp aTmpIdxReg;
if (!(eMode & UpdateMode::Negative) && !(eMode & UpdateMode::Delete))
{
- const SwRedlineTable& rTable = GetDoc().getIDocumentRedlineAccess().GetRedlineTable();
- SwRedlineTable::size_type n = GetDoc().getIDocumentRedlineAccess().GetRedlinePos(*this, RedlineType::Any);
- for( ; n < rTable.size(); ++n )
+ std::vector<SwRangeRedline*> vMyRedlines;
+ // walk the list of SwIndex 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);
+ pContentNodeIndex = pContentNodeIndex->GetNext();
+ }
+ std::sort(vMyRedlines.begin(), vMyRedlines.end());
+ vMyRedlines.erase( std::unique( vMyRedlines.begin(), vMyRedlines.end() ), vMyRedlines.end() );
+ for (SwRangeRedline* pRedl : vMyRedlines)
{
- SwRangeRedline* pRedl = rTable[ n ];
if ( pRedl->HasMark() )
{
SwPosition* const pEnd = pRedl->End();