remm 2004/03/08 15:46:37 Modified: util/java/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java Log: - The optimized write (direct writing when data appended is the size of the buffer and the buffer is empty) works good when we would want to overflow only when the data is actually bigger than the buffer. - Add flag to allow disabling this. Revision Changes Path 1.19 +6 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java Index: ByteChunk.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ByteChunk.java 5 Mar 2004 13:06:13 -0000 1.18 +++ ByteChunk.java 8 Mar 2004 23:46:37 -0000 1.19 @@ -92,6 +92,7 @@ private ByteOutputChannel out = null; private boolean isOutput=false; + private boolean optimizedWrite=true; /** * Creates a new, uninitialized ByteChunk object. @@ -158,6 +159,10 @@ isSet=true; } + public void setOptimizedWrite(boolean optimizedWrite) { + this.optimizedWrite = optimizedWrite; + } + public void setEncoding( String enc ) { this.enc=enc; } @@ -285,7 +290,7 @@ // If the buffer is empty and the source is going to fill up all the // space in buffer, may as well write it directly to the output, // and avoid an extra copy - if ( len == limit && end == start) { + if ( optimizedWrite && len == limit && end == start) { out.realWriteBytes( src, off, len ); return; } 1.13 +7 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java Index: CharChunk.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- CharChunk.java 5 Mar 2004 13:08:00 -0000 1.12 +++ CharChunk.java 8 Mar 2004 23:46:37 -0000 1.13 @@ -72,6 +72,8 @@ private CharInputChannel in = null; private CharOutputChannel out = null; + private boolean optimizedWrite=true; + /** * Creates a new, uninitialized CharChunk object. */ @@ -126,6 +128,10 @@ } + public void setOptimizedWrite(boolean optimizedWrite) { + this.optimizedWrite = optimizedWrite; + } + public void setChars( char[] c, int off, int len ) { recycle(); isSet=true; @@ -251,7 +257,7 @@ // Optimize on a common case. // If the source is going to fill up all the space in buffer, may // as well write it directly to the output, and avoid an extra copy - if ( len == limit && end == start) { + if ( optimizedWrite && len == limit && end == start) { out.realWriteChars( src, off, len ); return; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]