jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1522593 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
Date Thu, 12 Sep 2013 14:25:09 GMT
Author: mduerig
Date: Thu Sep 12 14:25:09 2013
New Revision: 1522593

URL: http://svn.apache.org/r1522593
Log:
OAK-1015 Optimise path parsing
Heuristic shortcutting path parsing

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java?rev=1522593&r1=1522592&r2=1522593&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
Thu Sep 12 14:25:09 2013
@@ -110,7 +110,7 @@ public class NamePathMapperImpl implemen
                 if (index == 0) {
                     elements.add(p);
                 } else {
-                    elements.add(p + "[" + index + "]");
+                    elements.add(p + '[' + index + ']');
                 }
                 return true;
             }
@@ -162,7 +162,25 @@ public class NamePathMapperImpl implemen
             return this.idManager.getPath(jcrPath.substring(1, length - 1));
         }
 
+        // Shortcut iff the JCR path does not start with a dot, does not contain any of
+        // {}[]/ and if it contains a colon the session does not have local re-mappings.
+        boolean hasLocalMappings = hasSessionLocalMappings();
+        boolean shortcut = length > 0 && jcrPath.charAt(0) != '.';
+        for (int i = 0; shortcut && i < length; i++) {
+            char c = jcrPath.charAt(i);
+            if (c == '{' || c == '}' || c == '[' || c == ']' || c == '/') {
+                shortcut = false;
+            } else if (c == ':') {
+                shortcut = !hasLocalMappings;
+            }
+        }
+
+        if (shortcut) {
+            return jcrPath;
+        }
+
         final StringBuilder parseErrors = new StringBuilder();
+
         PathListener listener = new PathListener() {
             @Override
             public void error(String message) {



Mime
View raw message