tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <>
Subject Re: [OT] Performance with many small requests
Date Wed, 13 May 2009 13:16:45 GMT
Christopher Schultz wrote:

>> Since a String object is immutable, one should always use a
>> StringBuffer (preferably a StringBuilder, these days) when you are
>> constructing strings in a piecemeal fashion, then convert to String
>> when complete.
> This advice is good when constructing a long string in a loop or across
> a long series of statements. If you are just concatenating a bunch of
> string together to make a big one in a single statement, go ahead and
> use the + operator: the compiler is smart enough to convert the entire
> thing into a StringBuilder (a non-synchronized replacement for
> StringBuffer) expression that gets good performance without making your
> code look like crap.
I was wondering about that.  It certainly seemed like a good place for a 
smart compiler to fix things up, but didn't know if it actually did or 
not.  I don't do a lot of that, but enough of it that it becomes a style 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message