You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <ug...@apache.org> on 2004/04/17 17:13:53 UTC
Re: cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/ant AntBuildGenerator.java CocoonTask.java
Il giorno 17/apr/04, alle 15:31, Antonio Gallardo ha scritto:
> I think it is a good programming practice plus:
>
> It saves resources.
No, it does not.
``String literals-or, more generally, strings that are the values of
constant expressions (§15.28)-are "interned" so as to share unique
instances, using the method String.intern.''
(http://java.sun.com/docs/books/jls/second_edition/html/
lexical.doc.html#101083)
This means, unless I'm seriously mistaken, that you can always use ""
instead of StringUtils.EMPTY without using a single bit of memory more.
And there's no GC involved.
It's just obfuscation without any efficiecy gain.
> Did you really think it is better to make a:
>
> Boolean b = new Boolean(true) instead of
>
> Boolean b = Boolean.TRUE
Never said that.
> Both expresion got the same result, but the first innecesary create
> another Object on the memory. That later the garbage collector need to
> free. This is my POV. The same happen with
>
> StringUtils.EMPTY vs. ""
I'm afraid you are wrong about this, dear friend.
> I really believe in the code reutilization. Jakarta commons lang is
> part
> of the core of Cocoon. Why we need to wrote the same code over and
> over?
There is NO code to write or reuse in this case. A simple "" is enough.
Ugo
Re: cvs commit:
cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/ant
AntBuildGenerator.java CocoonTask.java
Posted by Antonio Gallardo <ag...@agssa.net>.
Ugo Cei dijo:
> Il giorno 17/apr/04, alle 15:31, Antonio Gallardo ha scritto:
>
>> I think it is a good programming practice plus:
>>
>> It saves resources.
>
> No, it does not.
>
> ``String literals-or, more generally, strings that are the values of
> constant expressions (§15.28)-are "interned" so as to share unique
> instances, using the method String.intern.''
>
> (http://java.sun.com/docs/books/jls/second_edition/html/
> lexical.doc.html#101083)
>
> This means, unless I'm seriously mistaken, that you can always use ""
> instead of StringUtils.EMPTY without using a single bit of memory more.
> And there's no GC involved.
Thanks for pointing out the error. You are right. I will rewrote it as it
maybe. The change was really meaningless and the original code too.
Best Regards,
Antonio Gallardo.