From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120976 invoked by alias); 27 Sep 2016 08:32: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 120959 invoked by uid 89); 27 Sep 2016 08:32:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=cheat, Hx-languages-length:1300 X-HELO: paperclip.tbsaunde.org Received: from tbsaunde.org (HELO paperclip.tbsaunde.org) (66.228.47.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Sep 2016 08:32:37 +0000 Received: from ball (fanzine.igalia.com [91.117.99.155]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 79BD1C073; Tue, 27 Sep 2016 08:32:35 +0000 (UTC) Date: Tue, 27 Sep 2016 08:50:00 -0000 From: Trevor Saunders To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA 01/22] Change selttest.c to use use std::vector Message-ID: <20160927084049.naw5nx64smlzpqxg@ball> References: <1474949330-4307-1-git-send-email-tom@tromey.com> <1474949330-4307-2-git-send-email-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1474949330-4307-2-git-send-email-tom@tromey.com> User-Agent: NeoMutt/20160910 (1.7.0) X-SW-Source: 2016-09/txt/msg00361.txt.bz2 On Mon, Sep 26, 2016 at 10:08:29PM -0600, Tom Tromey wrote: > This patch changes selftest.c to use std::vector rather than VEC. > > I think this is a small net plus. Because we're using C++03, we I'd agree, hopefully we can throw VEC in the trash some day. Relatedly we should probably move gcc's hash table stuff to include/ sooner rather than later so we can similarly get rid of htab. > unfortunately don't all the possible benefits here; namely, iterating I think you missed get in that sentence. > over a vector is still a pain. For reference, in C++11 the loop would > be just: > > for (auto f : tests) its debatable, but imho its not necessarily obvious what the type of the local is when you use auto to iterate over vectors especially when they are members or globals like here. > +static std::vector tests; should we use a pointer to avoid the static initializer? > - for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i) > + for (std::vector::iterator iter = tests.begin (); > + iter != tests.end (); > + ++iter) I believe you can "cheat" here and just use the function pointer type, because the sane implementation of iterators over vectors is pointers. Trev