Skip to content
Permalink
Browse files
A few optimizations
git-svn-id: https://svn.apache.org/repos/asf/activemq/activemq-protobuf/trunk@745651 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
chirino committed Feb 18, 2009
1 parent d9ad523 commit 37c65a589a02fa6361014eb16b4de9af4c114e7a
Showing 2 changed files with 11 additions and 7 deletions.
@@ -18,9 +18,7 @@ static public Buffer toUnframedBuffer(MessageBuffer message) {
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 @@ static public Buffer toFramedBuffer(MessageBuffer message) {
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);
@@ -450,13 +450,21 @@ private void generateMethodFreeze(MessageDescriptor m, String bufferClassName) {
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();

}

/**

0 comments on commit 37c65a5

Please sign in to comment.