activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r745651 - in /activemq/activemq-protobuf/trunk/activemq-protobuf/src/main/java/org/apache/activemq/protobuf: MessageBufferSupport.java compiler/AltJavaGenerator.java
Date Wed, 18 Feb 2009 21:10:08 GMT
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();
+
     }
     
     /**



Mime
View raw message