Inefficient use StringBuffer or StringBuilder[Optimization|clean-up] {Package: con.sun. * java.lang*} (original) (raw)

Tom Hawtin tom.hawtin at oracle.com
Fri Jun 7 14:09:09 UTC 2013


On 07/06/2013 14:54, Andrew Haley wrote:

On 06/07/2013 02:18 PM, Otávio Gonçalves de Santana wrote:

sb.append(" xxx: [" + getXXX() + "]\n");

for this: sb.append(" xxx: [").append(getXXX()).append("]\n"); Hmm. I wonder that a JIT can't do this automatically. Perhaps it already does; I haven't looked.

The capacity of the StringBuilder may be different for the two statements. So even a "high-level rewriting" wouldn't be sufficiently equivalent.

Tom



More information about the core-libs-dev mailing list