Suggestion: Add the method isEmpty in the classes StringBuilder and StringBuffer
me at hildeberto.com
Thu Feb 14 08:15:02 UTC 2013
I think the "+" syntax in all possible cases with the maximal performance
would be the best option indeed. While we are not there yet, we could go
for this small change to improve existing code since the difference of
performance is significant.
To make this proposal more explicit, I'm going to propose a patch soon.
Thanks for the constructive discussion!
On Tue, Feb 12, 2013 at 2:32 PM, Ulf Zibis <Ulf.Zibis at cosoco.de> wrote:
> Am 12.02.2013 01:45, schrieb Vitaly Davidovich:
>> javac will not replace concat ops across loop iterations, it will replace
>> whichever ones are inside one loop iteration. This will still create
>> temporary StringBuilder instances.
>> As for JIT optimizing further, it would have to fully unroll the loop to
>> have a chance at eliminating this; I'd be really surprised if loops with
>> nontrivial (and non compile time constant) trip counts get eliminated. I'd
>> also not rely on JIT here and do the "right" thing manually :). You also
>> may not have C2 compiler available or may not even be running on hotspot.
> Thanks for your clarification, Vitaly.
> I was just advocating not to throw away readable syntax for suspicious
> performance advantage.
> So this brings me to a new idea:
> Extend the "+"-syntax over all classes of CharSequence !!!
Hildeberto Mendonça, Ph.D
Twitter: https://twitter.com/htmfilho <http://www.cejug.org>
More information about the core-libs-dev