summaryrefslogtreecommitdiff
path: root/include/cppuhelper/weakref.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-02-21 16:00:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-22 12:27:55 +0100
commit27352b81638f2f1e792ab48ec532eaacf6f61718 (patch)
treeeb744c30643272b219d59f2782ffc96f62bf379c /include/cppuhelper/weakref.hxx
parent6ccdd0d164b16da9a13ab5d8290a1a0f041caaf7 (diff)
Add XWeak constructor and operator= to uno::WeakReference
which is faster since we can skip the UNO_QUERY. Change-Id: Id95ad9f3568213e974bd13659d92d4ea94dbfbd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130282 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/cppuhelper/weakref.hxx')
-rw-r--r--include/cppuhelper/weakref.hxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/cppuhelper/weakref.hxx b/include/cppuhelper/weakref.hxx
index 9b41df598340..a5858b2e8805 100644
--- a/include/cppuhelper/weakref.hxx
+++ b/include/cppuhelper/weakref.hxx
@@ -42,6 +42,7 @@ namespace uno
{
class OWeakRefListener;
+class XWeak;
/** The WeakReferenceHelper holds a weak reference to an object.
@@ -79,6 +80,16 @@ public:
*/
WeakReferenceHelper( const css::uno::Reference< css::uno::XInterface > & xInt );
+#if defined LIBO_INTERNAL_ONLY
+ /** Initialize this reference with the hard interface reference xWeak. This
+ is faster than the XInterface constructor because we can skip doing an
+ UNO_QUERY.
+
+ @param xWeak another hard interface reference
+ */
+ WeakReferenceHelper( const css::uno::Reference< css::uno::XWeak > & xWeak );
+#endif
+
/** Releases this reference.
*/
~WeakReferenceHelper();
@@ -102,6 +113,17 @@ public:
WeakReferenceHelper & SAL_CALL operator = (
const css::uno::Reference< css::uno::XInterface > & xInt );
+#if defined LIBO_INTERNAL_ONLY
+ /** Releases this reference and takes over hard reference xWeak. This
+ is faster than the XInterface constructor because we can skip doing an
+ UNO_QUERY.
+
+ @param xWeak another hard reference
+ */
+ WeakReferenceHelper & operator = (
+ const css::uno::Reference< css::uno::XWeak > & xWeak );
+#endif
+
/** Returns true if both weak refs reference to the same object.
@param rObj another weak ref
@@ -176,6 +198,18 @@ public:
const css::uno::Reference< interface_type > & xInt )
{ WeakReferenceHelper::operator=(xInt); return *this; }
+#if defined LIBO_INTERNAL_ONLY
+ /** Releases this reference and takes over hard reference xWeak. This
+ is faster than the XInterface constructor because we can skip doing an
+ UNO_QUERY.
+
+ @param xWeak another hard reference
+ */
+ WeakReference & operator = (
+ const css::uno::Reference< css::uno::XWeak > & xWeak )
+ { WeakReferenceHelper::operator=(xWeak); return *this; }
+#endif
+
/** Gets a hard reference to the object.
@return hard reference or null, if the weakly referenced interface has gone