ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Skeet" <jon.sk...@peramon.com>
Subject RE: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Exit.java Filter.java FixCRLF.java GenerateKey.java Get.java Jar.java
Date Thu, 11 Apr 2002 14:55:33 GMT
> from the top of my head you may have something like this:
> 
> "aaa" + "bbb" -> "aaabbb"

Guaranteed by the JLS.

> "aaa" + "bbb" + z  -> new StringBuffer("aaabbb").append(z).toString()

Yup, I think that's guaranteed too, but it depends on precedence order.

> "aaa" + "bbb" + z + "ccc" -> new
> StringBuffer("aaa").append("bbb").append(z).append("ccc").toString()

If the previous one is guaranteed, this should be:

new StringBuffer ("aaabbb").append(z).append ("ccc").toString();

Certainly that's the case with:

("aaa"+"bbb")+z+"ccc" - I can never remember the Java precedence order, but I believe they're
equivalent.

> I also remember that in some cases one compiler may use the empty
> StringBuffer ctor instead of the String one.

Yup - that's left up to the compiler.

(A really good compiler would work out some kind of reasonable guess at a buffer size too,
but I don't know of any that do that.)

Jon

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


Mime
View raw message