james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject Strings to StringBuffer
Date Mon, 29 Jul 2002 19:27:50 GMT
Folks, if we're going to make the change from String to StringBuffer for
things, may I please ask that it be kept in what I consider the more
readable form?  What I mean is that instead of converting

   log("text" + var + "more text" + anothervar);


   StringBuffer logBuffer = new StringBuffer("text");
   logBuffer.append("more text");

I would prefer to see:

   log(new StringBuffer(128).append(text).append(var).append("more

I prefer that style, as did the authors of the StringBuffer class.

However, more important than style is that although the new
StringBuffer(128) is arbitrarily chosen for the example, it is important to
provide a reasonable initial buffer size.  If you use StringBuffer(), the
size defaults to 16.  If you use StringBuffer(String), you only get 16 bytes
more than the length of the initial string.  You will lose the performance
benefits you wanted from StringBuffer, because it will have to call
expandCapacity() multiple times.

YMMV, but this is my request/suggestion/proposal.

	--- Noel

To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>

View raw message