jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1292292 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
Date Wed, 22 Feb 2012 13:48:42 GMT
Author: thomasm
Date: Wed Feb 22 13:48:42 2012
New Revision: 1292292

URL: http://svn.apache.org/viewvc?rev=1292292&view=rev
Log:
Bugfix; use more obvious method names.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java?rev=1292292&r1=1292291&r2=1292292&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
Wed Feb 22 13:48:42 2012
@@ -44,7 +44,7 @@ public class NodeListTrie implements Nod
         this.prefixLength = prefixLength;
         this.revId = revId;
         for (Child c : children) {
-            size += getList(c, false).size();
+            size += getList(c).size();
         }
     }
 
@@ -105,16 +105,18 @@ public class NodeListTrie implements Nod
             return false;
         }
         Child c = children.get(index);
-        NodeList list = getList(c, true);
+        NodeList list = getList(c);
         return list.containsKey(name);
     }
 
-    NodeList getList(Child c, boolean modify) {
+    NodeList getList(Child c) {
+        return c.id.getNode(map).getNodeList();
+    }
+
+    NodeList getListClone(Child c) {
         NodeImpl n = c.id.getNode(map);
-        if (modify) {
-            n = n.createClone(revId);
-            c.id = map.addNode(n);
-        }
+        n = n.createClone(revId);
+        c.id = map.addNode(n);
         return n.getNodeList();
     }
 
@@ -124,7 +126,7 @@ public class NodeListTrie implements Nod
             index = -index - 1;
         }
         Child c = children.get(index);
-        NodeList list = getList(c, true);
+        NodeList list = getList(c);
         return list.get(name);
     }
 
@@ -132,9 +134,9 @@ public class NodeListTrie implements Nod
         int i = 0;
         for (; i < children.size(); i++) {
             Child c = children.get(i);
-            long size = getList(c, false).size();
+            long size = getList(c).size();
             if (size > pos) {
-                NodeList list = getList(c, false);
+                NodeList list = getList(c);
                 return list.getName(pos);
             }
             pos -= size;
@@ -146,7 +148,7 @@ public class NodeListTrie implements Nod
         int i = 0;
         for (; i < children.size(); i++) {
             Child c = children.get(i);
-            long size = getList(c, false).size();
+            long size = getList(c).size();
             if (size > offset) {
                 break;
             }
@@ -164,7 +166,7 @@ public class NodeListTrie implements Nod
                     return true;
                 }
                 while (pos < children.size()) {
-                    it = getList(children.get(pos++), false).getNames(offset, remaining);
+                    it = getList(children.get(pos++)).getNames(offset, remaining);
                     offset = 0;
                     if (it.hasNext()) {
                         return true;
@@ -217,7 +219,7 @@ public class NodeListTrie implements Nod
             addChild(index, name, list);
         } else {
             Child c = children.get(index);
-            NodeList list = getList(c, true);
+            NodeList list = getListClone(c);
             list.add(name, x);
         }
         size++;
@@ -229,7 +231,7 @@ public class NodeListTrie implements Nod
             throw ExceptionFactory.get("Node not found: " + name);
         } else {
             Child c = children.get(index);
-            NodeList list = getList(c, true);
+            NodeList list = getListClone(c);
             list.replace(name, x);
         }
     }
@@ -240,7 +242,7 @@ public class NodeListTrie implements Nod
             throw ExceptionFactory.get("Node not found: " + name);
         }
         Child c = children.get(index);
-        NodeList list = getList(c, true);
+        NodeList list = getListClone(c);
         return list.remove(name);
     }
 



Mime
View raw message