You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2022/10/09 09:02:29 UTC

[sling-org-apache-sling-jcr-resource] branch SLING-11614-optimize-listJcrChildren created (now bb3d2e9)

This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a change to branch SLING-11614-optimize-listJcrChildren
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git


      at bb3d2e9  SLING-11614 avoid duplicate creation of child node iterator

This branch includes the following new commits:

     new bb3d2e9  SLING-11614 avoid duplicate creation of child node iterator

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-jcr-resource] 01/01: SLING-11614 avoid duplicate creation of child node iterator

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a commit to branch SLING-11614-optimize-listJcrChildren
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git

commit bb3d2e9dcab41da64bfad950db87d01838c1f4cf
Author: Jörg Hoh <jo...@joerghoh.de>
AuthorDate: Sun Oct 9 11:02:09 2022 +0200

    SLING-11614 avoid duplicate creation of child node iterator
---
 .../sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java  | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
index dba7f67..9371aa5 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 
@@ -217,15 +218,13 @@ class JcrNodeResource extends JcrItemResource<Node> { // this should be package
         return null;
     }
 
-
-    // ---------- Descendable interface ----------------------------------------
-
     @Override
     @Nullable Iterator<Resource> listJcrChildren() {
         try {
-            if (getNode().hasNodes()) {
+        	NodeIterator iter = getNode().getNodes();
+            if (iter.hasNext()) {
                 return new JcrNodeResourceIterator(getResourceResolver(), path, version,
-                        getNode().getNodes(), this.helper, null);
+                        iter, this.helper, null);
             }
         } catch (final RepositoryException re) {
             LOGGER.error("listChildren: Cannot get children of " + this, re);