You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Casey Lucas <cl...@armassolutions.com> on 2001/02/10 00:03:44 UTC
BodyContentImpl optimization
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