From ec61093f2f9a40f18fb9a47a478804baf15ca521 Mon Sep 17 00:00:00 2001 From: Jukka Zitting Date: Tue, 11 Feb 2014 17:42:02 -0500 Subject: [PATCH] OAK-1417: Processing pending observation events does not scale linearly with the number of events Shortcut NamePathMapperImpl.getJcrPath() for the common case where there are no local namespace remappings. This removes the O(log n) cost of each Event.getPath() call, and helps drop the observed performance closer to O(n) than O(n log n) --- .../apache/jackrabbit/oak/namepath/NamePathMapperImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java index 98d8fa4..6270f60 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java @@ -92,6 +92,12 @@ public class NamePathMapperImpl implements NamePathMapper { if ("/".equals(oakPath)) { // avoid the need to special case the root path later on return "/"; + } else if (oakPath.isEmpty()) { + // empty path: map to "." + return "."; + } else if (getSessionLocalMappings().isEmpty()) { + // no local namespace mappings + return oakPath; } PathListener listener = new PathListener() { @@ -120,11 +126,6 @@ public class NamePathMapperImpl implements NamePathMapper { JcrPathParser.parse(oakPath, listener); - // empty path: map to "." - if (listener.elements.isEmpty()) { - return "."; - } - StringBuilder jcrPath = new StringBuilder(); for (String element : listener.elements) { if (element.isEmpty()) { -- 1.8.3.msysgit.0