include/comphelper/interfacecontainer4.hxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 1606f778e4cd3d8056aecbac3d13f5858361356a
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Dec 27 19:05:42 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Dec 27 20:57:37 2021 +0100

    reduce default cost of OInterfaceContainerHelper4
    
    most of these are never used, so rather store a pointer to a shared
    empty vector
    
    Change-Id: I4736794a31237c598d1188ef42f4210ea6d3f871
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127599
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/comphelper/interfacecontainer4.hxx 
b/include/comphelper/interfacecontainer4.hxx
index 04fafeadc0fd..e58b958629b9 100644
--- a/include/comphelper/interfacecontainer4.hxx
+++ b/include/comphelper/interfacecontainer4.hxx
@@ -114,7 +114,8 @@ template <class ListenerT> void 
OInterfaceIteratorHelper4<ListenerT>::remove()
 template <class ListenerT> class OInterfaceContainerHelper4
 {
 public:
-    OInterfaceContainerHelper4() {}
+    OInterfaceContainerHelper4();
+
     /**
       Return the number of Elements in the container. Only useful if you have 
acquired
       the mutex.
@@ -205,6 +206,12 @@ private:
     OInterfaceContainerHelper4(const OInterfaceContainerHelper4&) = delete;
     OInterfaceContainerHelper4& operator=(const OInterfaceContainerHelper4&) = 
delete;
 
+    static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>>& 
DEFAULT()
+    {
+        static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> 
SINGLETON;
+        return SINGLETON;
+    }
+
 private:
     template <typename EventT> class NotifySingleListener
     {
@@ -227,6 +234,12 @@ private:
     };
 };
 
+template <class T>
+inline OInterfaceContainerHelper4<T>::OInterfaceContainerHelper4()
+    : maData(OInterfaceContainerHelper4<T>::DEFAULT())
+{
+}
+
 template <class T>
 template <typename FuncT>
 inline void OInterfaceContainerHelper4<T>::forEach(FuncT const& func)

Reply via email to