From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11872 invoked by alias); 24 Apr 2014 20:28:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11862 invoked by uid 89); 24 Apr 2014 20:28:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Apr 2014 20:28:38 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3OKSUn3006197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Apr 2014 16:28:30 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3OKSTCH004317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 24 Apr 2014 16:28:30 -0400 Message-ID: <535973ED.5010302@redhat.com> Date: Thu, 24 Apr 2014 20:28:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 08/12] Iterator varobj_items by their availability References: <1392367471-13527-1-git-send-email-yao@codesourcery.com> <1392367471-13527-9-git-send-email-yao@codesourcery.com> In-Reply-To: <1392367471-13527-9-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00513.txt.bz2 On 02/14/2014 12:44 AM, Yao Qi wrote: > V2: > - Fix changelog entry. > - Add comments. > - Use XNEW. > - Fix typo. > - Update copyright year for new added file. > > gdb: > > 2014-02-14 Pedro Alves > Yao Qi > > * Makefile.in (SFILES): Add varobj-iter-avail.c. > (COMMON_OBS): Add varobj-iter-avail.o. > * varobj-iter-avail.c: New file. > * varobj-iter.h (avail_varobj_get_iterator): Declare. > * varobj.c (varobj_get_iterator): Add one more argument > 'lang_ops'. All callers updated. > Return iterator for available children. This looks good to me, but I have one little thing I'd like to ask... > +static int > +varobj_value_unavailable (struct value *val) > +{ [snip] > +/* Implementation of the `next' method for available-children-only > + varobj iterators. */ > + > +static varobj_item * > +avail_varobj_iter_next (struct varobj_iter *self) > +{ > + struct avail_varobj_iter *dis = (struct avail_varobj_iter *) self; > + int num_children = dis->lang_ops->number_of_children (self->var); > + int raw_index = self->next_raw_index; > + varobj_item *item = NULL; > + > + for (; raw_index < num_children; raw_index++) > + { > + struct value *child_value > + = dis->lang_ops->value_of_child (self->var, raw_index); > + > + /* The "fake" children will have NULL values. */ > + if (child_value == NULL || !varobj_value_unavailable (child_value)) > + { Maybe it's just me (and maybe because I am especially slow today), but I find the use of double-negatives slow me/my comprehension down. The above test reads, "if child_value is NULL or child_value is not unavailable..." What do you think about inverting the name of this function and the test like so: if (child_value == NULL || varobj_value_available (child_value)) /* ... */ Then that reads, "if child_value is NULL or the value is available," which is immensely easier for me to comprehend. [But maybe I'm the only one?] Keith