jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r813274 - in /jackrabbit/branches/1.4/jackrabbit-core: ./ src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
Date Thu, 10 Sep 2009 07:21:40 GMT
Author: mreutegg
Date: Thu Sep 10 07:21:40 2009
New Revision: 813274

URL: http://svn.apache.org/viewvc?rev=813274&view=rev
Log:
JCR-1988: AbstractRecord does inefficient List.indexOf()

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/   (props changed)
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java

Propchange: jackrabbit/branches/1.4/jackrabbit-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 10 07:21:40 2009
@@ -1 +1 @@
-/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,683268,686688,691181,691550,694164,698200,698209,709142,718981,727402,733080,734366
+/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,683268,686688,691181,691550,694164,698200,698209,709142,718981,727402,733080,734366,746932

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=813274&r1=813273&r2=813274&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
Thu Sep 10 07:21:40 2009
@@ -32,12 +32,13 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.uuid.Constants;
 import org.apache.jackrabbit.uuid.UUID;
+import org.apache.commons.collections.BidiMap;
+import org.apache.commons.collections.bidimap.DualHashBidiMap;
 
 import javax.jcr.NamespaceException;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -56,9 +57,9 @@
     private static final byte UUID_INDEX = 'I';
 
     /**
-     * UUID index.
+     * Maps NodeId to Integer index.
      */
-    private final ArrayList uuidIndex = new ArrayList();
+    private final BidiMap nodeIdIndex = new DualHashBidiMap();
 
     /**
      * Namespace resolver.
@@ -218,13 +219,13 @@
             if (index == -1) {
                 return null;
             } else {
-                return (NodeId) uuidIndex.get(index);
+                return (NodeId) nodeIdIndex.getKey(new Integer(index));
             }
         } else if (uuidType == UUID_LITERAL) {
             byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
             readFully(b);
             NodeId nodeId = new NodeId(new UUID(b));
-            uuidIndex.add(nodeId);
+            nodeIdIndex.put(nodeId, new Integer(nodeIdIndex.size()));
             return nodeId;
         } else {
             String msg = "Unknown UUID type found: " + uuidType;
@@ -266,10 +267,12 @@
      * @return cache index of existing entry or <code>-1</code> to indicate the
entry was added
      */
     private int getOrCreateIndex(NodeId nodeId) {
-        int index = uuidIndex.indexOf(nodeId);
-        if (index == -1) {
-            uuidIndex.add(nodeId);
+        Integer index = (Integer) nodeIdIndex.get(nodeId);
+        if (index == null) {
+            nodeIdIndex.put(nodeId, new Integer(nodeIdIndex.size()));
+            return -1;
+        } else {
+            return index.intValue();
         }
-        return index;
     }
 }
\ No newline at end of file



Mime
View raw message