cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allan Erskine" <a.ersk...@cs.ucl.ac.uk>
Subject Re: AW: cvs commit: xml-cocoon/webapp/WEB-INF web.xml
Date Tue, 03 Apr 2001 19:49:17 GMT
> > > > Quoting cziegeler@apache.org:
> > > >
> > > > >   +        String value = conf.getInitParameter("allow-reload");
> > > > >   +        if (value == null || value.equals("yes") == true) {
> > > >
> > > > Why are you writing the last statement that way? Would it be better
to
> > > > write it
> > > > like
> > > >
> > > >      if ("yes".equals(value) == true) {
> > > >
> > > > That way you don't need the additional test against null.

> But you've changed the meaning of the code - namely, changing the default
> value from yes to no. If the default value should be yes, you could write
it
> as
>
> if (!"no".equals (value)) {
>
> but I think Carsten's original code is less confusing, and the performance
> difference is negligible in this case!
>

Carsten's code will also optimise to a single op for default values (no
strings will be constructed - with many default values, those obsessed
enough may even notice the difference)...don't know where the style
originates, but definitely used a lot in C/C++

£0.02

----- Original Message -----
From: "Robin Green" <greenrd@hotmail.com>
To: <cocoon-dev@xml.apache.org>
Sent: Tuesday, April 03, 2001 6:25 PM
Subject: Re: AW: cvs commit: xml-cocoon/webapp/WEB-INF web.xml


> Giacomo Pati <giacomo@apache.org> wrote:
> >Quoting Carsten Ziegeler <cziegeler@sundn.de>:
> >
> > > > Giacomo Pati wrote:
> > > > Quoting cziegeler@apache.org:
> > > >
> > > > >   +        String value = conf.getInitParameter("allow-reload");
> > > > >   +        if (value == null || value.equals("yes") == true) {
> > > >
> > > > Why are you writing the last statement that way? Would it be better
to
> > > > write it
> > > > like
> > > >
> > > >      if ("yes".equals(value) == true) {
> > > >
> > > > That way you don't need the additional test against null.
> > > >
> > > Yes, you're right,
> > >
> > > I accidentally used our company coding style.
> > > Sorry for that, I will change it as soon as my cvs works again.
> >
> >This has nothing to do with coding style. It's only simpler code IMHO.
>
> But you've changed the meaning of the code - namely, changing the default
> value from yes to no. If the default value should be yes, you could write
it
> as
>
> if (!"no".equals (value)) {
>
> but I think Carsten's original code is less confusing, and the performance
> difference is negligible in this case!
>
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


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


Mime
View raw message