[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r34714 - trunk/subversion/libsvn_wc

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Mon, 15 Dec 2008 16:21:48 +0000

C. Michael Pilato wrote:
> Hyrum K. Wright wrote:
> > - if (is_empty)
> > - *has_props = FALSE;
> > - else
> > - *has_props = TRUE;
> > + *has_props = !is_empty;
> >
> > return SVN_NO_ERROR;
> > }
>
> For some reason, I was thinking we tried to avoid doing this. Something
> about the logical operations not necessarily resulting in our specific TRUE
> and FALSE values? I dunno, and I could be completely misremembering.

Nah; it's absolutely good. Maybe you're thinking of not wanting to use
the "!" operator on a non-Boolean value, such as

  svn_boolean_t has_no_props(apr_hash_t *prop_hash)
  {
    return !prop_hash;
  }

That usage is generally avoided in our code base, I think.

> You could also use a 1-liner ternary:
>
> *has_props = is_empty ? FALSE : TRUE;

Eww. But still not quite as bad as the totally redundant

  boolean_value ? TRUE : FALSE

- Julian

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=984535
Received on 2008-12-15 17:22:19 CET

This is an archived mail posted to the Subversion Dev mailing list.