sw/source/core/txtnode/ndhints.cxx |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

New commits:
commit cdac145768488dc11b32b744bc753ab16aa08c6e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Nov 25 14:11:55 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Nov 25 18:21:21 2022 +0100

    reduce cost of SwpHints::Check
    
    Takes it from 20m to 2m on some tests.
    
    Change-Id: Idc02a299ebdffaf4bcd99612e92190f6b9619021
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143296
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/txtnode/ndhints.cxx 
b/sw/source/core/txtnode/ndhints.cxx
index 167d5aee4f1d..a9b9d4b6c51c 100644
--- a/sw/source/core/txtnode/ndhints.cxx
+++ b/sw/source/core/txtnode/ndhints.cxx
@@ -213,6 +213,12 @@ bool SwpHints::Check(bool bPortionsMerged) const
         }
     }
 
+    // --- cross checks ---
+    // same pointers in both arrays
+    auto tmpHintsByEnd = m_HintsByEnd;
+    std::sort(tmpHintsByEnd.begin(), tmpHintsByEnd.end(), CompareSwpHtStart);
+    CHECK_ERR( tmpHintsByEnd == m_HintsByStart, "HintsCheck: the two arrays do 
not contain the same set of pointers" );
+
     for( size_t i = 0; i < Count(); ++i )
     {
         // --- check Starts ---
@@ -249,18 +255,6 @@ bool SwpHints::Check(bool bPortionsMerged) const
         nLastEnd = nIdx;
         pLastEnd = pHtEnd;
 
-        // --- cross checks ---
-
-        // 5) same pointers in both arrays
-        if (std::lower_bound(m_HintsByStart.begin(), m_HintsByStart.end(), 
const_cast<SwTextAttr*>(pHt), CompareSwpHtStart) == m_HintsByStart.end())
-            nIdx = COMPLETE_STRING;
-
-        CHECK_ERR( COMPLETE_STRING != nIdx, "HintsCheck: no GetStartOf" );
-
-        // 6) same pointers in both arrays
-        if (std::lower_bound(m_HintsByEnd.begin(), m_HintsByEnd.end(), 
const_cast<SwTextAttr*>(pHt), CompareSwpHtEnd()) == m_HintsByEnd.end())
-            nIdx = COMPLETE_STRING;
-
         CHECK_ERR( COMPLETE_STRING != nIdx, "HintsCheck: no GetEndOf" );
 
         // 7a) character attributes in array?

Reply via email to