tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Casey Lucas" <clu...@armassolutions.com>
Subject BodyContentImpl optimization
Date Fri, 09 Feb 2001 23:03:44 GMT

Hopefully this is the right place for the following information.  If
not, I'm sorry.

I don't really do active development on tomcat (cvs updates, etc) but
while profiling our application, I noticed a couple of minor improvements
that could be made to BodyContentImpl.java.  Specifically, in
'reAllocBuff', a buffer allocation and arraycopy can be removed.  In
'clear', a buffer allocation can be removed.  We use a lot of tags and
some of them have large bodies (causing calls to reAllocBuff), so both
reAllocBuff and clear showed up as "hot spots".


The diff is below:

110,111c110
<         char[] tmp = new char [bufferSize]
<       System.arraycopy(cb, 0, tmp, 0, cb.length)
---
>         char[] tmp = null
116c115
<           cb = new char [bufferSize + Constants.DEFAULT_BUFFER_SIZE]
---
>           tmp = new char [bufferSize + Constants.DEFAULT_BUFFER_SIZE]
119c118
<           cb = new char [bufferSize + len]
---
>           tmp = new char [bufferSize + len]
122c121,122
<       System.arraycopy(tmp, 0, cb, 0, tmp.length)
---
>       System.arraycopy(cb, 0, tmp, 0, cb.length)
>    cb = tmp
502,503d501
<             cb = new char [Constants.DEFAULT_BUFFER_SIZE]
<           bufferSize = Constants.DEFAULT_BUFFER_SIZE


I hope someone can make use of this.

-Casey

Mime
View raw message