Wyss Patrick wrote:
... generating unnecessary
String objects ...
// to log a new message
buf.clear();
buf.append("some string here");
this creates a String object on every call as well...
it's the same as:
buf.append(new String("some string here"));
how much would you bet :-]
I wrote
> > No, I don't think so. "some string here" is a constant. It gets
> > interned. No new object gets created on each call. The String gets
> > created once when the class loads.
>
> how much would you bet :-]
>
ooops i guess i was wrong here :-}
apologies for opening my big mouth ;-)
--
> Internally, I'm sure the info() method is calling Object.toString(),
> which does create a new String object.
you are right Layout.format will turn it into a String. smart appenders do this
using StringBuffer/Builder.
format could format to a StringBuffer/Builder but this does not realy matte