Friends, going through the source code looking for
places to optimize the critical path (i.e. the path
taken when no error or log message is performed),
I went through adding StringBuffers where there were
three or more strings to concatenate.

I found an enigma.

In several places, where the code was already using
a StringBuffer, I found code snippets like this:

buffer.append("<" + prefix + ":" + name + "/>");

This gets expanded into the much more complex code as
follows:

buffer.append(
    new StringBuffer(
        new StringBuffer(
            new StringBuffer(
                new StringBuffer("<").append(prefix).toString()
            ).append(":").toString()
        ).append(name).toString()
    ).append("/>").toString()
);

That means four additional StringBuffers were created
behind the scenes.  This is ludicrous when we are already
using StringBuffers--and wasteful of resources.

Instead, please write the code to explicitly take advantage
of the StringBuffer when it is available:

buffer.append("<").append(prefix).append(":").append(name).append("/>");

This is more respectful of the environment, and is much quicker
to execute on any JVM.

Please, be mindful in the future.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to