include/comphelper/multiinterfacecontainer2.hxx | 31 +++--------------------- 1 file changed, 5 insertions(+), 26 deletions(-)
New commits: commit d8a526eabe3a7256c1637307e8de74c54e5df4eb Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Nov 30 21:36:08 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Dec 1 08:06:09 2021 +0100 improve OMultiTypeInterfaceContainerHelperVar2::disposeAndClear no need to create an array, just move/empty the map in one step Change-Id: I6480d671ca0542c4a871756df1eeee257087db5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126154 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/comphelper/multiinterfacecontainer2.hxx b/include/comphelper/multiinterfacecontainer2.hxx index e15c26733198..b9eea1bd86dc 100644 --- a/include/comphelper/multiinterfacecontainer2.hxx +++ b/include/comphelper/multiinterfacecontainer2.hxx @@ -170,36 +170,15 @@ public: */ inline void disposeAndClear(const css::lang::EventObject& rEvt) { - typename InterfaceMap::size_type nSize = 0; - OInterfaceContainerHelper2** ppListenerContainers = nullptr; - { - ::osl::MutexGuard aGuard(rMutex); - nSize = m_aMap.size(); - if (nSize) - { - typedef OInterfaceContainerHelper2* ppp; - ppListenerContainers = new ppp[nSize]; - - typename InterfaceMap::iterator iter = m_aMap.begin(); - typename InterfaceMap::iterator end = m_aMap.end(); - - typename InterfaceMap::size_type i = 0; - while (iter != end) - { - ppListenerContainers[i++] = (*iter).second.get(); - ++iter; - } - } - } - // create a copy, because do not fire event in a guarded section - for (typename InterfaceMap::size_type i = 0; i < nSize; i++) + InterfaceMap tempMap; { - if (ppListenerContainers[i]) - ppListenerContainers[i]->disposeAndClear(rEvt); + ::osl::MutexGuard aGuard(rMutex); + tempMap = std::move(m_aMap); } - delete[] ppListenerContainers; + for (auto& rPair : m_aMap) + rPair.second->disposeAndClear(rEvt); } /**