[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: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: Mon, 15 Dec 2008 10:23:40 -0600

C. Michael Pilato wrote:
> Hyrum K. Wright wrote:
>> Author: hwright
>> Date: Mon Dec 15 07:53:36 2008
>> New Revision: 34714
>>
>> Log:
>> * subversion/libsvn_wc/props.c
>> (svn_wc__has_props): Avoid an if-else by directly assigning a boolean
>> value.
>>
>> Modified:
>> trunk/subversion/libsvn_wc/props.c
>>
>> Modified: trunk/subversion/libsvn_wc/props.c
>> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/props.c?pathrev=34714&r1=34713&r2=34714
>> ==============================================================================
>> --- trunk/subversion/libsvn_wc/props.c Mon Dec 15 07:48:41 2008 (r34713)
>> +++ trunk/subversion/libsvn_wc/props.c Mon Dec 15 07:53:36 2008 (r34714)
>> @@ -2772,10 +2772,7 @@ svn_wc__has_props(svn_boolean_t *has_pro
>> svn_wc__props_working, FALSE, pool));
>> SVN_ERR(empty_props_p(&is_empty, prop_path, pool));
>>
>> - 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.

I really hope this isn't the case. We've got a boolean type system, so let's
treat booleans as first class types, complete with assignment. Is the concern
that someone might attempt to do something like the following:

  if (*has_props == TRUE)
    ...

and it may not evaluate properly? I'd personally be surprised if we do any
explicit comparisons of boolean values (and if we do, we shouldn't be).

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

-Hyrum

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=984536

Received on 2008-12-15 17:24:00 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.