On 28 December 2014 at 12:34, Felix Schumacher
<[email protected]> 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

Reply via email to