jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1464420 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
Date Thu, 04 Apr 2013 10:23:33 GMT
Author: angela
Date: Thu Apr  4 10:23:33 2013
New Revision: 1464420

URL: http://svn.apache.org/r1464420
Log:
OAK-527: permissions (wip, avoid recalculating path in ImmutableTree)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java?rev=1464420&r1=1464419&r2=1464420&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
Thu Apr  4 10:23:33 2013
@@ -16,11 +16,7 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-
 import java.util.Iterator;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -30,13 +26,15 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.kernel.KernelNodeState;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.spi.security.Context;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * ImmutableTree...
  * FIXME: merge with ReadOnlyTree
@@ -46,6 +44,8 @@ public final class ImmutableTree extends
     private final ParentProvider parentProvider;
     private final TypeProvider typeProvider;
 
+    private String path;
+
     public ImmutableTree(@Nonnull NodeState rootState) {
         this(ParentProvider.ROOTPROVIDER, "", rootState, TypeProvider.EMPTY);
     }
@@ -87,26 +87,22 @@ public final class ImmutableTree extends
 
     @Override
     public String getPath() {
-        if (isRoot()) {
-            // shortcut
-            return "/";
-        }
-
-        NodeState nodeState = getNodeState();
-        if (nodeState instanceof KernelNodeState) {
-            return ((KernelNodeState) nodeState).getPath();
-        } else {
-            StringBuilder sb = new StringBuilder();
-            buildPath(sb);
-            return sb.toString();
-        }
-    }
-
-    private void buildPath(StringBuilder sb) {
-        if (!isRoot()) {
-            getParent().buildPath(sb);
-            sb.append('/').append(getName());
+        if (path == null) {
+            if (isRoot()) {
+                // shortcut
+                path = "/";
+            } else {
+                StringBuilder sb = new StringBuilder();
+                ImmutableTree parent = getParent();
+                sb.append(parent.getPath());
+                if (!parent.isRoot()) {
+                    sb.append('/');
+                }
+                sb.append(getName());
+                path = sb.toString();
+            }
         }
+        return path;
     }
 
     @Override



Mime
View raw message