Suggestion: Add the method isEmpty in the classes StringBuilder and StringBuffer

Ulf Zibis Ulf.Zibis at CoSoCo.de
Tue Feb 12 13:32:05 UTC 2013


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 !!!

-Ulf




More information about the core-libs-dev mailing list