[opencms-dev] Ver6: Article Management Module is out!!!
Alexander Kandzior
alex at opencms.org
Tue Feb 8 13:44:44 CET 2005
> > 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.
> > 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":-)
AFAIK either the Java compiler or at last the hotspot JVM will remove the
method calls and replace them directly with the inlined code from the
booleanValue() method. So no performance loss using the standard methods.
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com
More information about the opencms-dev
mailing list