[opencms-dev] Ver6: Article Management Module is out!!!

Robert Petermeier robert2.0 at gmx.de
Tue Feb 8 13:18:06 CET 2005


Robert Burén <robert.buren at gmail.com> wrote:
> Ok, this is silly, but...
>
> Boolean.valueOf() doesn't actually create a new instance of Boolean.
> It returns either Boolean.TRUE or Boolean.FALSE, which are public
> static final members of Boolean.

You are completely right here,

> And so, your code isn't actually even slighter more efficient 

but here you are wrong. When calling Boolean.valueOf(String) the 
following methods are invoked:

->     Boolean.valueOf(String s)
->     Boolean.toBoolean(String name)
[which contains only this one line:
           return ((name != null) && name.equalsIgnoreCase("true"));
]
->     Boolean#booleanValue()

So I needed three method calls less to achieve the same and may still 
claim that my version is "slightly more efficient":-)

You may call this discussion silly and you are most probably right in 
this particular case, but I do think that, especially in server-side 
programming, it's *generally* a good idea to spend a thought or two on 
execution speed and memory usage.

When reading the sourcecode of OpenCms you might find some spots where a 
nice OOD was dropped in favor of greater efficiency (at least that was 
my impression sometimes).

> and the
> code should be written like Alexander said, simply because that's what
> those methods are there for, and the code is clearer.

Agreed:-)


Regards,
Robert



More information about the opencms-dev mailing list