[ 
https://issues.apache.org/jira/browse/JCR-2762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919754#action_12919754
 ] 

Thomas Mueller commented on JCR-2762:
-------------------------------------

I would rename the methods from readInt() / writeInt() to readVarInt() / 
writeVarInt(). The "var" stands for "variable size". Reason: this following 
code looks confusing until you understand readInt() doesn't do the same as 
in.readInt():

+                    if (version >= BundleBinding.VERSION_3) {
+                        len = readInt();
+                    } else {
+                        len = in.readInt();
+                    }

I would avoid recursion here (the same for writeInt):

+    private int readInt() throws IOException {
+        int b = in.readUnsignedByte();
+        if ((b & 0x80) == 0) {
+            return b;
+        } else {
+            return readInt() << 7 | b & 0x7f;
+        }
+    }

Mainly for performance (but also to avoid reading too much if the data is 
corrupt). Instead, I would use the J3 implementations at 
http://svn.apache.org/repos/asf/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
 

> Optimize bundle serialization
> -----------------------------
>
>                 Key: JCR-2762
>                 URL: https://issues.apache.org/jira/browse/JCR-2762
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Jukka Zitting
>            Priority: Minor
>         Attachments: 0001-JCR-2762-Optimize-bundle-serialization.patch, 
> 0002-JCR-2762-Optimize-bundle-serialization.patch, 
> 0003-JCR-2762-Optimize-bundle-serialization.patch
>
>
> There are a number of ways we could use to make bundle serialization more 
> optimized. Thomas has already done some work on this in the Jackrabbit 3 
> sandbox, and I'd like to apply some of the optimizations also to the trunk.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to