sc/source/filter/inc/stylesbuffer.hxx |    2 ++
 sc/source/filter/oox/stylesbuffer.cxx |   20 ++++++++++++--------
 vcl/inc/svdata.hxx                    |    3 ++-
 3 files changed, 16 insertions(+), 9 deletions(-)

New commits:
commit a2d8fe60153364d9f94de344e47a57907a98354c
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Dec 22 10:31:46 2025 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Sat Dec 27 04:28:13 2025 +0100

    tdf#166684 used unordered_set for maCacheOwners
    
    maCacheOwners is pretty much a write-only data-structure, we very seldom 
read it,
    which makes unordered_set a better fit.
    Shaves about 1% off the time here.
    
    Change-Id: Ife37d56c64ecfa0e658ee42d40f425d2bc3ac670
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196065
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 5ae6816dcb69..682db8544008 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -55,6 +55,7 @@
 #include <optional>
 #include <vector>
 #include <unordered_map>
+#include <unordered_set>
 #include "schedulerimpl.hxx"
 #include <basegfx/DrawCommands.hxx>
 
@@ -424,7 +425,7 @@ struct ImplSVData
     css::uno::Reference< css::lang::XComponent > mxAccessBridge;
     std::unique_ptr<vcl::SettingsConfigItem> mpSettingsConfigItem;
     std::unordered_map< int, OUString > maPaperNames;
-    o3tl::sorted_vector<CacheOwner*> maCacheOwners;
+    std::unordered_set<CacheOwner*> maCacheOwners;
 
     css::uno::Reference<css::i18n::XCharacterClassification> m_xCharClass;
 
commit 10d85b215e7086086f99cc95dc76947c3ab3869a
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Dec 22 11:53:08 2025 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Sat Dec 27 04:27:58 2025 +0100

    tdf#166684 avoid re-creating ExtConditional stylesheets
    
    there are a lot of them, and renaming them is expensive.
    
    Shaves 10% off load time.
    
    Change-Id: Ic5c3347367babd9156ceec94f78ef6f1017c6e4d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196088
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index 2078375318ff..295db8548509 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -35,6 +35,7 @@
 #include <docmodel/color/ComplexColor.hxx>
 #include <attarray.hxx>
 #include <vector>
+#include <unordered_set>
 
 class ScPatternCache;
 enum class ScTableStyleElement;
@@ -958,6 +959,7 @@ private:
     DxfVector           maExtDxfs;          /// List of differential extlst 
cell styles.
     mutable DxfStyleMap maDxfStyles;        /// Maps DXF identifiers to Calc 
style sheet names.
     TableStyleVector    maTableStyles;
+    mutable std::unordered_set<sal_Int32> maExtConditionalStyles;  /// DXF 
identifiers for ExtCondition which have been mapped to styles.
 };
 
 } // namespace oox::xls
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 2380ec987648..322e3f4033ff 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -3247,16 +3247,20 @@ OUString StylesBuffer::createExtDxfStyle( sal_Int32 
nDxfId ) const
     {
         rStyleName = "ExtConditionalStyle_" + OUString::number(nDxfId + 1);
 
-        // Create a cell style. This may overwrite an existing style if
-        // one with the same name exists.
-        ScStyleSheet& rStyleSheet = ScfTools::MakeCellStyleSheet(
-                *getScDocument().GetStyleSheetPool(), rStyleName, true);
+        // use a map to avoid creating the same style more than once.
+        if (maExtConditionalStyles.insert(nDxfId).second)
+        {
+            // Create a cell style. This may overwrite an existing style if
+            // one with the same name exists.
+            ScStyleSheet& rStyleSheet = ScfTools::MakeCellStyleSheet(
+                    *getScDocument().GetStyleSheetPool(), rStyleName, true);
 
-        rStyleSheet.ResetParent();
-        SfxItemSet& rStyleItemSet =
-            rStyleSheet.GetItemSet();
+            rStyleSheet.ResetParent();
+            SfxItemSet& rStyleItemSet =
+                rStyleSheet.GetItemSet();
 
-        pDxf->fillToItemSet(rStyleItemSet);
+            pDxf->fillToItemSet(rStyleItemSet);
+        }
     }
 
     // on error: fallback to default style

Reply via email to