Author: remm Date: Fri Feb 9 17:32:10 2007 New Revision: 505604 URL: http://svn.apache.org/viewvc?view=rev&rev=505604 Log: - Set of minor optimizations. - Use getLength() less often. - Submitted by Arvind Srinivasan.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java tomcat/tc6.0.x/trunk/java/org/apache/jk/common/MsgAjp.java tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Fri Feb 9 17:32:10 2007 @@ -505,8 +505,9 @@ throws Exception { ByteChunk bc = uri.getByteChunk(); + int length = bc.getLength(); CharChunk cc = uri.getCharChunk(); - cc.allocate(bc.getLength(), -1); + cc.allocate(length, -1); String enc = connector.getURIEncoding(); if (enc != null) { @@ -540,10 +541,10 @@ byte[] bbuf = bc.getBuffer(); char[] cbuf = cc.getBuffer(); int start = bc.getStart(); - for (int i = 0; i < bc.getLength(); i++) { + for (int i = 0; i < length; i++) { cbuf[i] = (char) (bbuf[i + start] & 0xff); } - uri.setChars(cbuf, 0, bc.getLength()); + uri.setChars(cbuf, 0, length); } @@ -559,16 +560,17 @@ ByteChunk bc = mb.getByteChunk(); CharChunk cc = mb.getCharChunk(); - cc.allocate(bc.getLength(), -1); + int length = bc.getLength(); + cc.allocate(length, -1); // Default encoding: fast conversion byte[] bbuf = bc.getBuffer(); char[] cbuf = cc.getBuffer(); int start = bc.getStart(); - for (int i = 0; i < bc.getLength(); i++) { + for (int i = 0; i < length; i++) { cbuf[i] = (char) (bbuf[i + start] & 0xff); } - mb.setChars(cbuf, 0, bc.getLength()); + mb.setChars(cbuf, 0, length); } Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Fri Feb 9 17:32:10 2007 @@ -598,8 +598,9 @@ // Set the given bytes as the content ByteChunk bc = (ByteChunk) param; - bodyBytes.setBytes(bc.getBytes(), bc.getStart(), bc.getLength()); - request.setContentLength(bc.getLength()); + int length = bc.getLength(); + bodyBytes.setBytes(bc.getBytes(), bc.getStart(), length); + request.setContentLength(length); first = false; empty = false; replay = true; Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Fri Feb 9 17:32:10 2007 @@ -586,8 +586,9 @@ // Set the given bytes as the content ByteChunk bc = (ByteChunk) param; - bodyBytes.setBytes(bc.getBytes(), bc.getStart(), bc.getLength()); - request.setContentLength(bc.getLength()); + int length = bc.getLength(); + bodyBytes.setBytes(bc.getBytes(), bc.getStart(), length); + request.setContentLength(length); first = false; empty = false; replay = true; Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java Fri Feb 9 17:32:10 2007 @@ -585,9 +585,9 @@ protected void write(ByteChunk bc) { // Writing the byte chunk to the output buffer - System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, - bc.getLength()); - pos = pos + bc.getLength(); + int length = bc.getLength(); + System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, length); + pos = pos + length; } Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Fri Feb 9 17:32:10 2007 @@ -644,9 +644,9 @@ protected void write(ByteChunk bc) { // Writing the byte chunk to the output buffer - System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, - bc.getLength()); - pos = pos + bc.getLength(); + int length = bc.getLength(); + System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, length); + pos = pos + length; } Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java Fri Feb 9 17:32:10 2007 @@ -631,9 +631,9 @@ protected void write(ByteChunk bc) { // Writing the byte chunk to the output buffer - System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, - bc.getLength()); - pos = pos + bc.getLength(); + int length = bc.getLength(); + System.arraycopy(bc.getBytes(), bc.getStart(), buf, pos, length); + pos = pos + length; } @@ -756,14 +756,15 @@ public int doWrite(ByteChunk chunk, Response res) throws IOException { + int length = chunk.getLength(); if (useSocketBuffer) { socketBuffer.append(chunk.getBuffer(), chunk.getStart(), - chunk.getLength()); + length); } else { outputStream.write(chunk.getBuffer(), chunk.getStart(), - chunk.getLength()); + length); } - return chunk.getLength(); + return length; } Modified: tomcat/tc6.0.x/trunk/java/org/apache/jk/common/MsgAjp.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jk/common/MsgAjp.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jk/common/MsgAjp.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jk/common/MsgAjp.java Fri Feb 9 17:32:10 2007 @@ -165,8 +165,9 @@ byte[] bytes = bc.getBytes(); int start=bc.getStart(); - appendInt( bc.getLength() ); - cpBytes(bytes, start, bc.getLength()); + int length = bc.getLength(); + appendInt( length ); + cpBytes(bytes, start, length); appendByte(0); } Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java?view=diff&rev=505604&r1=505603&r2=505604 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Fri Feb 9 17:32:10 2007 @@ -414,15 +414,16 @@ result = bc.toString(); } else { CharChunk cc = tmpNameC; - cc.allocate(bc.getLength(), -1); + int length = bc.getLength(); + cc.allocate(length, -1); // Default encoding: fast conversion byte[] bbuf = bc.getBuffer(); char[] cbuf = cc.getBuffer(); int start = bc.getStart(); - for (int i = 0; i < bc.getLength(); i++) { + for (int i = 0; i < length; i++) { cbuf[i] = (char) (bbuf[i + start] & 0xff); } - cc.setChars(cbuf, 0, bc.getLength()); + cc.setChars(cbuf, 0, length); result = cc.toString(); cc.recycle(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]