diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-13 14:19:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-14 09:12:25 +0200 |
commit | d70f53a8269be31f0412926afa5ba826faed6633 (patch) | |
tree | cb0d391364033ba090e76c837eb5450d4dba48a7 /svl/source | |
parent | 76505bbd862b17b9b02a2d6e68bac308890dec70 (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 'svl/source')
-rw-r--r-- | svl/source/items/IndexedStyleSheets.cxx | 10 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 12 |
2 files changed, 11 insertions, 11 deletions
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx index b74cffb2a2c9..95d579a3231c 100644 --- a/svl/source/items/IndexedStyleSheets.cxx +++ b/svl/source/items/IndexedStyleSheets.cxx @@ -164,19 +164,19 @@ IndexedStyleSheets::GetNumberOfStyleSheetsWithPredicate(StyleSheetPredicate& pre return r; } -rtl::Reference<SfxStyleSheetBase> +SfxStyleSheetBase* IndexedStyleSheets::GetNthStyleSheetThatMatchesPredicate( unsigned n, StyleSheetPredicate& predicate, unsigned startAt) { - rtl::Reference<SfxStyleSheetBase> retval; + SfxStyleSheetBase* retval = nullptr; unsigned matching = 0; for (VectorType::const_iterator it = mStyleSheets.begin()+startAt; it != mStyleSheets.end(); ++it) { SfxStyleSheetBase *ssheet = it->get(); if (predicate.Check(*ssheet)) { if (matching == n) { - retval = *it; + retval = it->get(); break; } ++matching; @@ -223,11 +223,11 @@ IndexedStyleSheets::HasStyleSheet(const rtl::Reference< SfxStyleSheetBase >& sty return false; } -rtl::Reference< SfxStyleSheetBase > +SfxStyleSheetBase* IndexedStyleSheets::GetStyleSheetByPosition(unsigned pos) { if( pos < mStyleSheets.size() ) - return mStyleSheets.at(pos); + return mStyleSheets.at(pos).get(); return nullptr; } diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 9ffd2aa57062..01873c282455 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -437,7 +437,7 @@ SfxStyleSheetBase* SfxStyleSheetIterator::operator[](sal_uInt16 nIdx) SfxStyleSheetBase* retval = nullptr; if( IsTrivialSearch()) { - retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nIdx).get(); + retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nIdx); nCurrentPosition = nIdx; } else if(nMask == SfxStyleSearchBits::All) @@ -491,7 +491,7 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Next() if (nStyleSheets > newPosition) { nCurrentPosition = newPosition; - retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nCurrentPosition).get(); + retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nCurrentPosition); } } else if(nMask == SfxStyleSearchBits::All) @@ -502,8 +502,8 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Next() if (familyVector.size() > newPosition) { nCurrentPosition = newPosition; - unsigned stylePosition = familyVector.at(newPosition); - retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(stylePosition).get(); + unsigned stylePosition = familyVector[newPosition]; + retval = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(stylePosition); } } else @@ -533,7 +533,7 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Find(const OUString& rStr) } unsigned pos = positions.front(); - SfxStyleSheetBase* pStyle = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(pos).get(); + SfxStyleSheetBase* pStyle = pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(pos); nCurrentPosition = pos; pCurrentStyle = pStyle; return pCurrentStyle; @@ -971,7 +971,7 @@ SfxStyleSheetBasePool::GetIndexedStyleSheets() const return *pImpl->mxIndexedStyleSheets; } -rtl::Reference<SfxStyleSheetBase> +SfxStyleSheetBase* SfxStyleSheetBasePool::GetStyleSheetByPositionInIndex(unsigned pos) { return pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(pos); |