From 9fb6bc06ebf549e664eeffcb463842efd390283e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 13 May 2026 15:23:02 +0200 Subject: [PATCH] cool#15761 Speedup calc cursor / data-entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I suspect that what is happening here is that maDirtyTableColumnNames is getting a lot of entries and we are refreshing stuff more than we need to. Swap the loop ordering so that refresh each DB at most once. Change-Id: Iee629083a81dd52365af90a820a5a78a27f6c3ef Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2556 Reviewed-by: Tomaž Vajngerl Tested-by: Jenkins CPCI (cherry picked from commit 5d7371e71ecf7fc9a52d70e55f3060c0aab04d56) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206683 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- sc/inc/dbdata.hxx | 2 +- sc/source/core/tool/dbdata.cxx | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index ac8eb286e30f..b8b7d4146d3d 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -254,7 +254,7 @@ public: /** Refresh/update the column names with the header row's cell contents within the given range. */ - void RefreshTableColumnNames( ScDocument& rDoc, const ScRange& rRange ); + void RefreshTableColumnNames( ScDocument& rDoc, const ScRangeList& rRangeList ); /** Finds the column named rName and returns the corresponding offset within the table. diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 89c24e5691a3..218a4bd399c0 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -1538,7 +1538,7 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc ) mbTableColumnNamesDirty = false; } -void ScDBData::RefreshTableColumnNames( ScDocument& rDoc, const ScRange& rRange ) +void ScDBData::RefreshTableColumnNames( ScDocument& rDoc, const ScRangeList& rRangeList ) { // Header-less tables get names generated, completely empty a full refresh. if (mbTableColumnNamesDirty && (!HasHeader() || maTableColumnNames.empty())) @@ -1548,8 +1548,7 @@ void ScDBData::RefreshTableColumnNames( ScDocument& rDoc, const ScRange& rRange } // Check if this is affected for the range requested. - ScRange aIntersection( GetHeaderArea().Intersection( rRange)); - if (!aIntersection.IsValid()) + if (!rRangeList.Intersects(GetHeaderArea())) return; // Always fully refresh, only one cell of a range was broadcasted per area @@ -2294,14 +2293,12 @@ std::vector ScDBCollection::GetAllNamedDBsInArea(SCCOL nCol1, S void ScDBCollection::RefreshDirtyTableColumnNames() { - for (size_t i=0; i < maNamedDBs.maDirtyTableColumnNames.size(); ++i) + if (maNamedDBs.maDirtyTableColumnNames.empty()) + return; + for (auto const& it : maNamedDBs) { - const ScRange & rRange = maNamedDBs.maDirtyTableColumnNames[i]; - for (auto const& it : maNamedDBs) - { - if (it->AreTableColumnNamesDirty()) - it->RefreshTableColumnNames( maNamedDBs.mrDoc, rRange); - } + if (it->AreTableColumnNamesDirty()) + it->RefreshTableColumnNames( maNamedDBs.mrDoc, maNamedDBs.maDirtyTableColumnNames); } maNamedDBs.maDirtyTableColumnNames.RemoveAll(); }