From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6473 invoked by alias); 28 Sep 2016 12:45:52 -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 6391 invoked by uid 89); 28 Sep 2016 12:45:51 -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=D*tbsaunde.org, keys, management 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; Wed, 28 Sep 2016 12:45:41 +0000 Received: from ball (fanzine.igalia.com [91.117.99.155]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id CF93AC056; Wed, 28 Sep 2016 12:45:38 +0000 (UTC) Date: Wed, 28 Sep 2016 14:58: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: <20160928125425.l2c33kotjcixy7q4@ball> References: <1474949330-4307-1-git-send-email-tom@tromey.com> <1474949330-4307-2-git-send-email-tom@tromey.com> <20160927084049.naw5nx64smlzpqxg@ball> <87twd1z6a7.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87twd1z6a7.fsf@tromey.com> User-Agent: NeoMutt/20160910 (1.7.0) X-SW-Source: 2016-09/txt/msg00398.txt.bz2 On Tue, Sep 27, 2016 at 09:55:28AM -0600, Tom Tromey wrote: > >>>>> "Trevor" == Trevor Saunders writes: > > Trevor> I'd agree, hopefully we can throw VEC in the trash some day. Relatedly > Trevor> we should probably move gcc's hash table stuff to include/ sooner rather > Trevor> than later so we can similarly get rid of htab. > > That would be nice; though we could probably use std::set and std::map > in gdb as well. One wrinkle with hash tables is that they're sometimes > allocated on obstacks; would gcc's handle this? No, they don't support that at the moment, though I suppose it would be fine for keys or values to point into obstacks. Is there a good reason for this other than using obstacks to provide a sort of automatic memory management? > >> for (auto f : tests) > > Trevor> its debatable, but imho its not necessarily obvious what the type of the > Trevor> local is when you use auto to iterate over vectors especially when they > Trevor> are members or globals like here. > > Yeah, that's one drawback. > Often one actually wants "auto &f" in there. yeah, and not having that can sometimes be bad. > >> +static std::vector tests; > > Trevor> should we use a pointer to avoid the static initializer? > > I was on the fence about this one. > On the one hand, static initializers can be very bad. > On the other hand, this one in particular doesn't seem like it could > cause problems. yeah, I think its just zeroing some memory and then registering a static destructor. So its silly that its necessary at all, but whether to avoid it or not is just a perf question. Trev > >> - for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i) > >> + for (std::vector::iterator iter = tests.begin (); > >> + iter != tests.end (); > >> + ++iter) > > Trevor> I believe you can "cheat" here and just use the function pointer type, > Trevor> because the sane implementation of iterators over vectors is pointers. > > Yeah, or just loop using an int and index into the vector. > I'll see if that looks cleaner. > > Tom