jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: StringBuilder against compile time String concatenation
Date Sun, 28 Dec 2014 22:38:44 GMT
On 28 December 2014 at 12:34, Felix Schumacher
<felix.schumacher@internetallee.de> wrote:
> Hi all,
>
> in XPathUtil I have found the following code fragment:
>
>   log.debug(new
> StringBuilder("bla").append(blub).append("whatever").toString())
>
> which seems to me t be equivallent to
>
>   log.debug("bla"+blubb+"whatever")
>
> any reason to use the former?

I think originally the Java compiler was not clever enough to convert
mixed string and variable concatenation into a sequence of
StringBuilder.append calls.
I suspect the code originally used StringBuffer, which was then
converted to StringBuilder.

I agree there is no need to use explicit StringBuilder calls here.
However the log.debug call should be enclosed by

if (log.isDebugEnabled()) { }

if it is not already.

> Regards
>  Felix

Mime
View raw message