diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-14 17:02:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-19 20:34:10 +0200 |
commit | 378f15a48bcb9fc9676644c20541a943efcd5565 (patch) | |
tree | 2d7d4a9d60df42fcd6a142e59e996f1291bb0318 /svl | |
parent | 9afcfb48617d4dd25797d1e825244298bef52a83 (diff) |
tdf#94792 performance regression for xlsx with chart with >1000 data labels
this speeds things up by 30% for me
Change-Id: I7fa99e91b0b4f354329803b9c8fab827bd367dac
Reviewed-on: https://gerrit.libreoffice.org/55812
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 20083840700518d8c0ec314974249254eb859de7)
Reviewed-on: https://gerrit.libreoffice.org/55984
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/notify/SfxBroadcaster.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/svl/source/notify/SfxBroadcaster.cxx b/svl/source/notify/SfxBroadcaster.cxx index f4e00e860333..2e312a80ce85 100644 --- a/svl/source/notify/SfxBroadcaster.cxx +++ b/svl/source/notify/SfxBroadcaster.cxx @@ -124,13 +124,32 @@ void SfxBroadcaster::Forward(SfxBroadcaster& rBC, const SfxHint& rHint) void SfxBroadcaster::RemoveListener( SfxListener& rListener ) { DBG_TESTSOLARMUTEX(); - SfxListenerArr_Impl::iterator aIter = std::find( - mpImpl->m_Listeners.begin(), mpImpl->m_Listeners.end(), &rListener); - assert(aIter != mpImpl->m_Listeners.end()); // "RemoveListener: Listener unknown" + + // First, check the slots either side of the last removed slot, makes a significant + // difference when the list is large. + int positionOfRemovedElement = -1; + if (!mpImpl->m_RemovedPositions.empty()) + { + auto i = mpImpl->m_RemovedPositions.back(); + if (i < mpImpl->m_Listeners.size() - 2 && mpImpl->m_Listeners[i+1] == &rListener) + { + positionOfRemovedElement = i + 1; + } + else if (i > 0 && mpImpl->m_Listeners[i-1] == &rListener) + { + positionOfRemovedElement = i-1; + } + } + // then scan the whole list if we didn't find it + if (positionOfRemovedElement == -1) + { + SfxListenerArr_Impl::iterator aIter = std::find( + mpImpl->m_Listeners.begin(), mpImpl->m_Listeners.end(), &rListener); + positionOfRemovedElement = std::distance(mpImpl->m_Listeners.begin(), aIter); + } // DO NOT erase the listener, set the pointer to 0 // because the current continuation may contain this->Broadcast - *aIter = nullptr; - size_t positionOfRemovedElement = std::distance(mpImpl->m_Listeners.begin(), aIter); + mpImpl->m_Listeners[positionOfRemovedElement] = nullptr; mpImpl->m_RemovedPositions.push_back(positionOfRemovedElement); } |