You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/02/18 22:10:08 UTC

svn commit: r745651 - in /activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf: MessageBufferSupport.java compiler/AltJavaGenerator.java

Author: chirino
Date: Wed Feb 18 21:10:08 2009
New Revision: 745651

URL: http://svn.apache.org/viewvc?rev=745651&view=rev
Log:
A few optimizations

Modified:
    activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/MessageBufferSupport.java
    activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/AltJavaGenerator.java

Modified: activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/MessageBufferSupport.java
URL: http://svn.apache.org/viewvc/activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/MessageBufferSupport.java?rev=745651&r1=745650&r2=745651&view=diff
==============================================================================
--- activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/MessageBufferSupport.java (original)
+++ activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/MessageBufferSupport.java Wed Feb 18 21:10:08 2009
@@ -18,9 +18,7 @@
             CodedOutputStream output = new CodedOutputStream(baos);
             message.writeUnframed(output);
             Buffer rc = baos.toBuffer();
-            if( rc.length != size ) {
-                throw new IllegalStateException("Did not write as much data as expected.");
-            }
+            assert rc.length != size : "Did not write as much data as expected.";
             return rc;
         } catch (IOException e) {
             throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e);
@@ -34,9 +32,7 @@
             CodedOutputStream output = new CodedOutputStream(baos);
             message.writeFramed(output);
             Buffer rc = baos.toBuffer();
-            if( rc.length != size ) {
-                throw new IllegalStateException("Did not write as much data as expected.");
-            }
+            assert rc.length==size : "Did not write as much data as expected.";
             return rc;
         } catch (IOException e) {
             throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e);

Modified: activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/AltJavaGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/AltJavaGenerator.java?rev=745651&r1=745650&r2=745651&view=diff
==============================================================================
--- activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/AltJavaGenerator.java (original)
+++ activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/AltJavaGenerator.java Wed Feb 18 21:10:08 2009
@@ -450,13 +450,21 @@
         p("if( frozen==null ) {");
         indent();
         p("frozen = new "+bufferClassName+"(bean);");
-        p("frozen.serializedSizeUnframed();");
+        p("assert deepFreeze();");
         unindent();
         p("}");
         p("return frozen;");
         unindent();
         p("}");
         p();
+        p("private boolean deepFreeze() {");
+        indent();
+        p("frozen.serializedSizeUnframed();");
+        p("return true;");
+        unindent();
+        p("}");
+        p();
+
     }
     
     /**