activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r744106 - /activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java
Date Fri, 13 Feb 2009 13:20:58 GMT
Author: chirino
Date: Fri Feb 13 13:20:57 2009
New Revision: 744106

URL: http://svn.apache.org/viewvc?rev=744106&view=rev
Log:
Small optimization to avoid generating EOFExceptions while parsing from a in memory buffer.

Modified:
    activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java

Modified: activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java
URL: http://svn.apache.org/viewvc/activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java?rev=744106&r1=744105&r2=744106&view=diff
==============================================================================
--- activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java
(original)
+++ activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java
Fri Feb 13 13:20:57 2009
@@ -49,10 +49,12 @@
 
     public CodedInputStream(Buffer data) {
         this(new BufferInputStream(data));
+        limit = data.length;
     }
 
     public CodedInputStream(byte[] data) {
         this(new BufferInputStream(data));
+        limit = data.length;
     }
 
     /**
@@ -62,6 +64,10 @@
      * number.
      */
     public int readTag() throws IOException {
+        if( pos >= limit ) {
+            lastTag=0;
+            return 0;
+        }
         try {
             lastTag = readRawVarint32();
             if (lastTag == 0) {
@@ -75,6 +81,7 @@
         }
     }
 
+    
     /**
      * Verifies that the last call to readTag() returned the given tag value.
      * This is used to verify that a nested group ended with the correct end



Mime
View raw message