summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-08-24 14:11:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-27 15:53:30 +0100
commitbec2de27f676092bffdf8a639497602a9d13f675 (patch)
tree036b240ca3f9ab124112c0e68847ed72b23ea92c
parente7f2dcf29ba3d726549c38060723d8ae5f443c88 (diff)
tdf#64991 speed up loading large RTL documents
takes load time from 20s to 17s for me Several loops are very hot, so store the count()/size() value, instead of calling it on every iteration. Change-Id: I8c0b01721d27e4335dd613cf276dcdd0103633ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120945 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/text/itratr.cxx7
-rw-r--r--sw/source/core/text/pormulti.cxx8
-rw-r--r--sw/source/core/unocore/unoportenum.cxx5
3 files changed, 12 insertions, 8 deletions
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 5434e0038ac0..f76f15254e9f 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -260,6 +260,7 @@ void SwAttrIter::SeekFwd(const sal_Int32 nOldPos, const sal_Int32 nNewPos)
{
SwpHints const*const pHints(m_pTextNode->GetpSwpHints());
SwTextAttr *pTextAttr;
+ const auto nHintsCount = pHints->Count();
if ( m_nStartIndex ) // If attributes have been opened at all ...
{
@@ -267,7 +268,7 @@ void SwAttrIter::SeekFwd(const sal_Int32 nOldPos, const sal_Int32 nNewPos)
// As long as we've not yet reached the end of EndArray and the
// TextAttribute ends before or at the new position ...
- while ((m_nEndIndex < pHints->Count()) &&
+ while ((m_nEndIndex < nHintsCount) &&
((pTextAttr = pHints->GetSortedByEnd(m_nEndIndex))->GetAnyEnd() <= nNewPos))
{
// Close the TextAttributes, whose StartPos were before or at
@@ -278,7 +279,7 @@ void SwAttrIter::SeekFwd(const sal_Int32 nOldPos, const sal_Int32 nNewPos)
}
else // skip the not opened ends
{
- while ((m_nEndIndex < pHints->Count()) &&
+ while ((m_nEndIndex < nHintsCount) &&
(pHints->GetSortedByEnd(m_nEndIndex)->GetAnyEnd() <= nNewPos))
{
m_nEndIndex++;
@@ -287,7 +288,7 @@ void SwAttrIter::SeekFwd(const sal_Int32 nOldPos, const sal_Int32 nNewPos)
// As long as we've not yet reached the end of EndArray and the
// TextAttribute ends before or at the new position...
- while ((m_nStartIndex < pHints->Count()) &&
+ while ((m_nStartIndex < nHintsCount) &&
((pTextAttr = pHints->Get(m_nStartIndex))->GetStart() <= nNewPos))
{
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 1ea089b106e1..ee1595496a6c 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -860,12 +860,14 @@ namespace sw {
}
if (m_pMerged)
{
- while (m_CurrentExtent < m_pMerged->extents.size())
+ const auto nExtentsSize = m_pMerged->extents.size();
+ while (m_CurrentExtent < nExtentsSize)
{
sw::Extent const& rExtent(m_pMerged->extents[m_CurrentExtent]);
if (SwpHints const*const pHints = rExtent.pNode->GetpSwpHints())
{
- while (m_CurrentHint < pHints->Count())
+ auto nHintsCount = pHints->Count();
+ while (m_CurrentHint < nHintsCount)
{
SwTextAttr const*const pHint(pHints->Get(m_CurrentHint));
if (rExtent.nEnd < pHint->GetStart())
@@ -881,7 +883,7 @@ namespace sw {
}
}
++m_CurrentExtent;
- if (m_CurrentExtent < m_pMerged->extents.size() &&
+ if (m_CurrentExtent < nExtentsSize &&
rExtent.pNode != m_pMerged->extents[m_CurrentExtent].pNode)
{
m_CurrentHint = 0; // reset
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index f02b880f00b8..b53d1d79c520 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -710,7 +710,8 @@ lcl_ExportHints(
//search for special text attributes - first some ends
size_t nEndIndex = 0;
sal_Int32 nNextEnd = 0;
- while(nEndIndex < pHints->Count() &&
+ const auto nHintsCount = pHints->Count();
+ while(nEndIndex < nHintsCount &&
(!pHints->GetSortedByEnd(nEndIndex)->GetEnd() ||
nCurrentIndex >= (nNextEnd = (*pHints->GetSortedByEnd(nEndIndex)->GetEnd()))))
{
@@ -791,7 +792,7 @@ lcl_ExportHints(
// then some starts
size_t nStartIndex = 0;
sal_Int32 nNextStart = 0;
- while(nStartIndex < pHints->Count() &&
+ while(nStartIndex < nHintsCount &&
nCurrentIndex >= (nNextStart = pHints->Get(nStartIndex)->GetStart()))
{
SwTextAttr * const pAttr = pHints->Get(nStartIndex);