commit | 9df21016b37fc372300553513361c3e55b94d352 | [log] [tgz] |
---|---|---|
author | Hiram R. Chirino <chirino@apache.org> | Fri Feb 13 13:20:57 2009 +0000 |
committer | Hiram R. Chirino <chirino@apache.org> | Fri Feb 13 13:20:57 2009 +0000 |
tree | 3e50953d4e2a8337621ad6a2129e612bb9c21e33 | |
parent | 6c1efb9bf36875a7648a18333dc9efecdb72ffce [diff] |
Small optimization to avoid generating EOFExceptions while parsing from a in memory buffer. git-svn-id: https://svn.apache.org/repos/asf/activemq/activemq-protobuf/trunk@744106 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java b/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java index 8b47e87..96dcf89 100644 --- a/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java +++ b/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/CodedInputStream.java
@@ -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