Re: [groovy-dev] Redundant code ? Efficiency ?
On Mon, 2009-06-01 at 09:54 -0500, Hamlet D'Arcy wrote:
> > prints out two newlines in a very inefficient way. Or am I missing
> > something deep and subtle?
>
> That is the strangest way I've ever seen 2 newlines printed!
OK, its not just me then.
I am wondering if we can just delete the method entirely. (I like
deleting code and having there be no test failures
> > (Assuming that the use of StringBuffer is not deeply tied in to making
> > Groovy thread safe that is
>
> Almost any local variable declaration of StringBuffer can be replaced
> by StringBuilder as long as it never escapes the method. Once the
> instance escapes, however, it can be very hard to reason about whether
> it is threadsafe to replace it. It can escape as either a return value
> or passed off to a new method. Replacing field declarations can
> usually be reasoned about given, again, that the instance never
> escapes.
Exactly. It just requires someone to have the time and do it
> > and probably noticeably speeding up Groovy.
>
> Really?
StringBuffer is "thread safe" which means it is monitored, which means
every operation on an instance requires obtaining its lock, which is
(Continue reading)