configmgr/source/access.cxx      |   14 +++++++-------
 configmgr/source/access.hxx      |    2 +-
 configmgr/source/childaccess.cxx |    2 +-
 configmgr/source/childaccess.hxx |    2 +-
 configmgr/source/rootaccess.cxx  |    2 +-
 configmgr/source/rootaccess.hxx  |    2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 0e08992f99bfd4aaa57a6b30b9e8a32ee5dc4a98
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Oct 31 15:55:44 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 31 18:11:02 2023 +0100

    reduce ref-counting traffic in configmgr
    
    we can return by const& from getNode
    
    Change-Id: If93c43fd2e910e2fb69d9bd0a9e3dc587133dfa8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158729
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 4bb66cb5f025..668192fee63c 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -132,7 +132,7 @@ void Access::releaseNondeleting() {
 }
 
 bool Access::isValue() {
-    rtl::Reference< Node > p(getNode());
+    const rtl::Reference< Node > & p(getNode());
     switch (p->kind()) {
     case Node::KIND_PROPERTY:
     case Node::KIND_LOCALIZED_VALUE:
@@ -331,7 +331,7 @@ css::uno::Type Access::getElementType() {
     assert(thisIs(IS_ANY));
     osl::MutexGuard g(*lock_);
     checkLocalizedPropertyAccess();
-    rtl::Reference< Node > p(getNode());
+    const rtl::Reference< Node > & p(getNode());
     switch (p->kind()) {
     case Node::KIND_LOCALIZED_PROPERTY:
         return mapType(
@@ -625,7 +625,7 @@ void Access::setName(OUString const & aName)
             {
                 rtl::Reference< Access > parent(getParentAccess());
                 if (parent.is()) {
-                    rtl::Reference< Node > node(getNode());
+                    const rtl::Reference< Node > & node(getNode());
                     if (! node->getTemplateName().isEmpty()) {
                         rtl::Reference< ChildAccess > other(
                             parent->getChild(aName));
@@ -1164,7 +1164,7 @@ void Access::removeByName(OUString const & aName)
                 aName, getXWeak());
         }
         if (getNode()->kind() == Node::KIND_GROUP) {
-            rtl::Reference< Node > p(child->getNode());
+            const rtl::Reference< Node >& p(child->getNode());
             if (p->kind() != Node::KIND_PROPERTY ||
                 !static_cast< PropertyNode * >(p.get())->isExtension())
             {
@@ -2048,7 +2048,7 @@ rtl::Reference< ChildAccess > 
Access::getSubChild(OUString const & path) {
             return rtl::Reference< ChildAccess >();
         }
         if (setElement) {
-            rtl::Reference< Node > p(parent->getNode());
+            const rtl::Reference< Node >& p(parent->getNode());
             switch (p->kind()) {
             case Node::KIND_LOCALIZED_PROPERTY:
                 if (!Components::allLocales(getRootAccess()->getLocale()) ||
@@ -2100,7 +2100,7 @@ css::beans::Property Access::asProperty() {
     css::uno::Type type;
     bool nillable;
     bool removable;
-    rtl::Reference< Node > p(getNode());
+    const rtl::Reference< Node >& p(getNode());
     switch (p->kind()) {
     case Node::KIND_PROPERTY:
         {
@@ -2225,7 +2225,7 @@ rtl::Reference< Access > Access::getNotificationRoot() {
 #if !defined NDEBUG
 bool Access::thisIs(int what) {
     osl::MutexGuard g(*lock_);
-    rtl::Reference< Node > p(getNode());
+    const rtl::Reference< Node >& p(getNode());
     Node::Kind k(p->kind());
     return (k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE &&
         ((what & IS_GROUP) == 0 || k == Node::KIND_GROUP) &&
diff --git a/configmgr/source/access.hxx b/configmgr/source/access.hxx
index 7b59e81cfdc8..daa5f1d1f6be 100644
--- a/configmgr/source/access.hxx
+++ b/configmgr/source/access.hxx
@@ -111,7 +111,7 @@ public:
     virtual std::vector<OUString> getRelativePath() = 0;
 
     virtual OUString getRelativePathRepresentation() = 0;
-    virtual rtl::Reference< Node > getNode() = 0;
+    virtual const rtl::Reference< Node > & getNode() = 0;
 
     virtual bool isFinalized() = 0;
 
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 8a8d581dd8d6..e0a9f9ac6cee 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -107,7 +107,7 @@ OUString ChildAccess::getRelativePathRepresentation() {
     return path.makeStringAndClear();
 }
 
-rtl::Reference< Node > ChildAccess::getNode() {
+const rtl::Reference< Node > & ChildAccess::getNode() {
     return node_;
 }
 
diff --git a/configmgr/source/childaccess.hxx b/configmgr/source/childaccess.hxx
index 6f060c2de827..f3948a08ab50 100644
--- a/configmgr/source/childaccess.hxx
+++ b/configmgr/source/childaccess.hxx
@@ -64,7 +64,7 @@ public:
     virtual std::vector<OUString> getRelativePath() override;
 
     virtual OUString getRelativePathRepresentation() override;
-    virtual rtl::Reference< Node > getNode() override;
+    virtual const rtl::Reference< Node > & getNode() override;
 
     virtual bool isFinalized() override;
 
diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx
index 94be58e8660b..122401f6b068 100644
--- a/configmgr/source/rootaccess.cxx
+++ b/configmgr/source/rootaccess.cxx
@@ -204,7 +204,7 @@ OUString RootAccess::getRelativePathRepresentation() {
     return OUString();
 }
 
-rtl::Reference< Node > RootAccess::getNode() {
+const rtl::Reference< Node > & RootAccess::getNode() {
     if (!node_.is()) {
         OUString canonic;
         int finalizedLayer;
diff --git a/configmgr/source/rootaccess.hxx b/configmgr/source/rootaccess.hxx
index 4eb90d36c0a6..a30975dd652d 100644
--- a/configmgr/source/rootaccess.hxx
+++ b/configmgr/source/rootaccess.hxx
@@ -94,7 +94,7 @@ private:
 
     virtual OUString getRelativePathRepresentation() override;
 
-    virtual rtl::Reference< Node > getNode() override;
+    virtual const rtl::Reference< Node > & getNode() override;
 
     virtual bool isFinalized() override;
 

Reply via email to