[haiku-commits] Re: r40399 - in haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap: . imap_lib

  • From: Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 9 Feb 2011 13:08:38 +0100

2011/2/9 Oliver Tappe <zooey@xxxxxxxxxxxxxxx>:
> On 2011-02-09 at 11:26:00 [+0100], Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
> wrote:
> [ ... ]
>>
>> > +void
>> > +FolderConfigWindow::_ApplyChanges()
>> > +{
>> > +       bool haveChanges = false;
>> > +       for (unsigned int i = 0; i < fFolderList.size(); i++) {
>> > +               FolderInfo& info = fFolderList[i];
>> > +               CheckBoxItem* item =
>> > (CheckBoxItem*)fFolderListView->ItemAt(i);
>> > +               if ((info.subscribed && !item->Checked())
>> > +                       || (!info.subscribed && item->Checked())) {
>> > +                       haveChanges = true;
>>
>> This check could be better written : if (info.subscribed ^ item->Checked())
>
> Hm, while that might be more readable, it's a bit dangerous, since ^ is
> *bitwise* exclusive or, so it relies on both arguments being boolean values
> in order to work as intended in this context. That may be the case here,
> though, I just can't judge from the code above.

Sure, one can add a logical negation to force boolean values :)
if (!info.subscribed ^ !item->Checked())

Bye,
Jérôme

Other related posts: