include/comphelper/interfacecontainer3.hxx |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

New commits:
commit c8a5312b82ff1d3305baabbd2362ed0706ba8ace
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 14 09:51:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jan 14 09:57:35 2022 +0100

    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.gran...@collabora.co.uk>

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
     {
@@ -246,6 +254,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)

Reply via email to