diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-14 09:51:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-14 09:57:35 +0100 |
commit | c8a5312b82ff1d3305baabbd2362ed0706ba8ace (patch) | |
tree | 24b6b59a92acfa560ed67ce535c556e8614b1e04 /include | |
parent | 2e162bb1e8521ad8cd8148e0a18adc3eebadd710 (diff) |
reduce default cost of OInterfaceContainerHelper3
most of these are never used, so rather store a pointer to a shared
empty vector
Change-Id: If5b8b82235171769420615147a0e0b316c237874
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128404
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/comphelper/interfacecontainer3.hxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/include/comphelper/interfacecontainer3.hxx b/include/comphelper/interfacecontainer3.hxx index 27008f064e8c..4b3d44bab69d 100644 --- a/include/comphelper/interfacecontainer3.hxx +++ b/include/comphelper/interfacecontainer3.hxx @@ -126,10 +126,8 @@ public: The lifetime must be longer than the lifetime of this object. */ - OInterfaceContainerHelper3(::osl::Mutex& rMutex_) - : mrMutex(rMutex_) - { - } + inline OInterfaceContainerHelper3(::osl::Mutex& rMutex_); + /** Return the number of Elements in the container. Only useful if you have acquired the mutex. @@ -224,6 +222,16 @@ private: OInterfaceContainerHelper3(const OInterfaceContainerHelper3&) = delete; OInterfaceContainerHelper3& operator=(const OInterfaceContainerHelper3&) = delete; + static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>, + o3tl::ThreadSafeRefCountingPolicy>& + DEFAULT() + { + static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>, + o3tl::ThreadSafeRefCountingPolicy> + SINGLETON; + return SINGLETON; + } + private: template <typename EventT> class NotifySingleListener { @@ -247,6 +255,13 @@ private: }; template <class T> +inline OInterfaceContainerHelper3<T>::OInterfaceContainerHelper3(::osl::Mutex& rMutex_) + : maData(OInterfaceContainerHelper3<T>::DEFAULT()) + , mrMutex(rMutex_) +{ +} + +template <class T> template <typename FuncT> inline void OInterfaceContainerHelper3<T>::forEach(FuncT const& func) { |