ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Panchenko <alex+n...@olmisoft.com>
Subject Re: Adding a methof to StringUtils
Date Wed, 19 Apr 2006 10:24:54 GMT
Kev Jackson wrote:

> As I've been hacking away today, I've been swapping a load of "" + "" +
> "" style code over to use StringBuffers.  I thought that perhaps there's 
> a potential use of a static method in StringUtils to construct these 
> strings from an array

Please, don't.

Modern compilers already implement string addition using StringBuffer
(1.4 already have this optimization, I don't remember about earlier
versions).

And 1.5 compiler can do it using StringBuilder which is faster.

if (dirCount >> 0) {
>   String[] args = {"Deleted ", ""+dirCount, " director", (dirCount == 1 
> ? "y" : "ies"), " from ", d.getAbsolutePath()};
>   log(StringUtils.messageAppender(args), quiet ? Project.MSG_VERBOSE : 
> verbosity);
> }

The effects of this are
- the compiler can't optimized string addition
- the code is difficult to read

-- 
Best regards,
 Alexey                            mailto:alex+news@olmisoft.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message