summaryrefslogtreecommitdiff
path: root/sc/source/core/data/stlpool.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-13 14:19:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-14 09:12:25 +0200
commitd70f53a8269be31f0412926afa5ba826faed6633 (patch)
treecb0d391364033ba090e76c837eb5450d4dba48a7 /sc/source/core/data/stlpool.cxx
parent76505bbd862b17b9b02a2d6e68bac308890dec70 (diff)
tdf#100894 freeze when editing calc file with bazillions of cond formatting
This does not fix the root cause of this problem, which is simply that the document has a bazillion style sheets. Either the program which exported this document is broken, or our importer is not correctly de- duplicating the imported stylesheets. Anyhow, I made performance improvements until I realised that it was simply going to be impossible to display that many stylesheets in our UI. But still, this bug was useful in flushing out some performance issues. The improvements, in order of decreasing importance are: (*) Use SfxStyleSheetIterator in SvxStyleToolBoxControl::FillStyleBox to avoid an O(n^2) situation where the pool repeatedly marks all the stylesheets as not-used, and then walks the document finding out if a stylesheet is used. Which is a waste of time because we're searching the documents pool, so of course they are all used. (*) Add a virtual method to avoid dynamic_cast (*) return raw pointers instead of returning rtl::Reference by value to avoid unnecessary reference counting. SfxStyleSheetIterator Change-Id: I15ff9c1846d3ed3e6f5655fa44c762f7619d547a Reviewed-on: https://gerrit.libreoffice.org/55751 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/data/stlpool.cxx')
-rw-r--r--sc/source/core/data/stlpool.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 416c758eb5b7..1ef20908c947 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -113,7 +113,7 @@ SfxStyleSheetBase* ScStyleSheetPool::Create( const OUString& rName,
SfxStyleSheetBase* ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle )
{
- OSL_ENSURE( dynamic_cast<const ScStyleSheet*>( &rStyle) != nullptr, "Invalid StyleSheet-class! :-/" );
+ OSL_ENSURE( rStyle.isScStyleSheet(), "Invalid StyleSheet-class! :-/" );
return new ScStyleSheet( static_cast<const ScStyleSheet&>(rStyle) );
}
@@ -423,14 +423,10 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFami
for (/**/;it != aFoundPositions.end(); ++it)
{
- SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(*it).get();
- ScStyleSheet* pSheet = nullptr;
+ SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(*it);
// we do not know what kind of sheets we have.
- pSheet = dynamic_cast<ScStyleSheet*>(pFound);
- if (pSheet != nullptr)
- {
- return pSheet;
- }
+ if (pFound->isScStyleSheet())
+ return static_cast<ScStyleSheet*>(pFound);
}
return nullptr;
}