jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r358273 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Date Wed, 21 Dec 2005 12:15:22 GMT
Author: stefan
Date: Wed Dec 21 04:15:17 2005
New Revision: 358273

URL: http://svn.apache.org/viewcvs?rev=358273&view=rev
Log:
optimized child node entry read-access methods in NodeState

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=358273&r1=358272&r2=358273&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Wed Dec 21 04:15:17 2005
@@ -205,14 +205,7 @@
      *         the specified <code>name</code>.
      */
     public synchronized boolean hasChildNodeEntry(QName name) {
-        Iterator iter = childNodeEntries.iterator();
-        while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-            if (name.equals(entry.getName())) {
-                return true;
-            }
-        }
-        return false;
+        return !childNodeEntries.get(name).isEmpty();
     }
 
     /**
@@ -237,20 +230,7 @@
      *         the specified <code>name</code> and <code>index</code>.
      */
     public synchronized boolean hasChildNodeEntry(QName name, int index) {
-        if (index < 1) {
-            throw new IllegalArgumentException("index is 1-based");
-        }
-        Iterator iter = childNodeEntries.iterator();
-        int count = 0;
-        while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-            if (name.equals(entry.getName())) {
-                if (++count == index) {
-                    return true;
-                }
-            }
-        }
-        return false;
+        return childNodeEntries.get(name, index) != null;
     }
 
     /**
@@ -275,20 +255,7 @@
      *         or <code>null</code> if there's no such entry.
      */
     public synchronized ChildNodeEntry getChildNodeEntry(QName nodeName, int index) {
-        if (index < 1) {
-            throw new IllegalArgumentException("index is 1-based");
-        }
-        Iterator iter = childNodeEntries.iterator();
-        int count = 0;
-        while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-            if (nodeName.equals(entry.getName())) {
-                if (++count == index) {
-                    return entry;
-                }
-            }
-        }
-        return null;
+        return childNodeEntries.get(nodeName, index);
     }
 
     /**
@@ -1067,7 +1034,7 @@
         class OrderedMapIterator implements ListIterator {
 
             final ListIterator keyIter;
-                final Map entries;
+            final Map entries;
 
             OrderedMapIterator(ListIterator keyIter, Map entries) {
                 this.keyIter = keyIter;



Mime
View raw message