sw/source/core/doc/docnum.cxx |   20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

New commits:
commit 79b931027ef682c71040cea8833a6f65e27f7982
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Aug 17 17:48:58 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Aug 17 21:50:07 2024 +0200

    tdf#158556 improve FindNumRulePtr
    
    we dont need to scan the table if the entry does not exist in the map
    Shaves 2% off the load time of a large DOCX file
    
    Change-Id: Idf001487ae4a25a37f63218f1e98dbd6cc2a6ed8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171978
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 9536bc443b79..6c0d2c84dc58 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2551,22 +2551,10 @@ std::set<OUString> SwDoc::GetUsedBullets()
 
 SwNumRule* SwDoc::FindNumRulePtr( const OUString& rName ) const
 {
-    SwNumRule * pResult = maNumRuleMap[rName];
-
-    if ( !pResult )
-    {
-        for (size_t n = 0; n < mpNumRuleTable->size(); ++n)
-        {
-            if ((*mpNumRuleTable)[n]->GetName() == rName)
-            {
-                pResult = (*mpNumRuleTable)[n];
-
-                break;
-            }
-        }
-    }
-
-    return pResult;
+    auto it = maNumRuleMap.find(rName);
+    if (it == maNumRuleMap.end())
+        return nullptr;
+    return it->second;
 }
 
 void SwDoc::AddNumRule(SwNumRule * pRule)

Reply via email to