jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r373551 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java
Date Mon, 30 Jan 2006 17:25:43 GMT
Author: stefan
Date: Mon Jan 30 09:25:36 2006
New Revision: 373551

URL: http://svn.apache.org/viewcvs?rev=373551&view=rev
Log:
JCR-307: improved performance when handling nodes with large number of child node entries
- reimplemented NodeState.ChildNodeEntries
- made ChildNodeEntry immutable again
- avoided unnecessary object creation when de-/serializing child node entries

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java?rev=373551&r1=373550&r2=373551&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/uuid/UUID.java
Mon Jan 30 09:25:36 2006
@@ -257,15 +257,7 @@
             buf.insert(FORMAT_POSITION4, '-');
             stringValue = buf.toString();
 */
-            char[] chars = new char[UUID_FORMATTED_LENGTH];
-            for (int i = 0, j = 0; i < 16; i++) {
-                chars[j++] = hexDigits[(rawBytes[i] >> 4) & 0x0f];
-                chars[j++] = hexDigits[rawBytes[i] & 0x0f];
-                if (i == 3 || i == 5 || i == 7 || i == 9) {
-                    chars[j++] = '-';
-                }
-            }
-            stringValue = new String(chars);
+            stringValue = bytesToString(rawBytes);
             /** XXX end modification by stefan@apache.org */
         }
         return stringValue;
@@ -507,5 +499,38 @@
 
         return new UUID(raw);
     }*/
+    /** XXX end modification by stefan@apache.org */
+
+    /** XXX begin modification by stefan@apache.org */
+    public static String bytesToString(byte[] bytes) {
+        if (bytes.length != UUID_BYTE_LENGTH) {
+            throw new IllegalArgumentException();
+        }
+        char[] chars = new char[UUID_FORMATTED_LENGTH];
+        for (int i = 0, j = 0; i < UUID_BYTE_LENGTH; i++) {
+            chars[j++] = hexDigits[(bytes[i] >> 4) & 0x0f];
+            chars[j++] = hexDigits[bytes[i] & 0x0f];
+            if (i == 3 || i == 5 || i == 7 || i == 9) {
+                chars[j++] = '-';
+            }
+        }
+        return new String(chars);
+    }
+
+    public static byte[] stringToBytes(String uuid) {
+        if (uuid.length() != UUID_FORMATTED_LENGTH) {
+            throw new IllegalArgumentException();
+        }
+        byte[] ba = new byte[UUID_BYTE_LENGTH];
+        for (int i = 0, j = 0; i < UUID_FORMATTED_LENGTH; i += 2) {
+            if (i == FORMAT_POSITION1 || i == FORMAT_POSITION2
+                    || i == FORMAT_POSITION3 || i == FORMAT_POSITION4) {
+                // skip '-'
+                i++;
+            }
+            ba[j++] = (byte) Integer.parseInt(uuid.substring(i, i + 2), 16);
+        }
+        return ba;
+    }
     /** XXX end modification by stefan@apache.org */
 }



Mime
View raw message