larryi      2003/12/05 16:50:08

  Modified:    util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  Port optimization from CharChunk to prevent needless allocation of byte
  arrays.
  
  Revision  Changes    Path
  1.16      +9 -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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ByteChunk.java    12 Sep 2003 12:58:53 -0000      1.15
  +++ ByteChunk.java    6 Dec 2003 00:50:08 -0000       1.16
  @@ -324,6 +324,14 @@
            return;
        }
   
  +        // Optimize on a common case.
  +        // 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) {
  +            out.realWriteBytes( src, off, len );
  +            return;
  +        }
        // if we have limit and we're below
        if( len <= limit - end ) {
            // makeSpace will grow the buffer to the limit,
  @@ -452,7 +460,7 @@
        
        // limit < buf.length ( the buffer is already big )
        // or we already have space XXX
  -     if( desiredSize < buff.length ) {
  +     if( desiredSize <= buff.length ) {
            return;
        }
        // grow in larger chunks
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to