From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109194 invoked by alias); 29 Nov 2018 19:17:36 -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 109178 invoked by uid 89); 29 Nov 2018 19:17:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1311, invest X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Nov 2018 19:17:34 +0000 Received: by mail-wm1-f66.google.com with SMTP id g67so3385302wmd.2 for ; Thu, 29 Nov 2018 11:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5Us0uSSBC5FiLi9kL1yA7CRrWGWp6GMiPVYwdv0vCMA=; b=NKttZ731u65bASRWVCh5b9C7mDvpV7R/z2/2IrlaUe9JgyVxNca8PJKTFMTtzPCSz9 0tnNAUgIyCJ1207jWJeJ6Y4EKIav/XM10WDIEL4VBn2bLboq+wr/ERrIufsYF+UxA9BN BRfH7H6SOZcyEl4sLXpO5gNvKSvcDvAg8q09cL93TFVfVVUK1A8zCaGKGxlZT6rq+pI8 14bcXnn+q/n/SOM2snDrtj39EX0xu1w7BnAXFplTVz9DPJmUU+FLbGNQoPlqrVYcIFpw JfWtuxu13ItYgK2KiTj5/0Cb6hppCT9n2czHYTp9kflV2BAZeZJaW+h1Lnbkrn7ZQXmT LKog== Return-Path: Received: from localhost (host86-156-236-171.range86-156.btcentralplus.com. [86.156.236.171]) by smtp.gmail.com with ESMTPSA id s66sm3072696wmf.34.2018.11.29.11.17.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Nov 2018 11:17:31 -0800 (PST) Date: Thu, 29 Nov 2018 19:17:00 -0000 From: Andrew Burgess To: Pedro Alves Cc: gdb-patches@sourceware.org, jimw@sifive.com, palmer@sifive.com, jhb@FreeBSD.org Subject: Re: [PATCH 3/4] gdb/riscv: Create each unique target description only once Message-ID: <20181129191729.GH18841@embecosm.com> References: <84ce42bd83dc3d67bd312c4c8772171dd5bf1182.1543509416.git.andrew.burgess@embecosm.com> <6277aa2c-c64e-e7d2-07d9-444ce80ef170@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6277aa2c-c64e-e7d2-07d9-444ce80ef170@redhat.com> X-Fortune: What color is a chameleon on a mirror? X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00547.txt.bz2 * Pedro Alves [2018-11-29 18:12:29 +0000]: > On 11/29/2018 04:48 PM, Andrew Burgess wrote: > > > + > > + /* Add TDESC into the cache, a target description created to match > > + FEATURES. */ > > + void add (const struct riscv_gdbarch_features features, > > + const target_desc *tdesc) > > + { > > + feature_tdesc_pair p (features, tdesc); > > + m_tdesc_list.push_back (p); > > + } > > + > > +private: > > + > > + /* Map from a feature set to the corresponding target description. */ > > + typedef std::pair > + const target_desc *> feature_tdesc_pair; > > + > > + /* List of all target descriptions we've previously seen. */ > > + std::vector m_tdesc_list; > > +}; > > Did you consider an unordered_map instead of this whole class here? > See xml-tdesc.c's xml_cache. If there's a reason the custom data > structure is preferred, I think that warrants a comment. No, the class only exists to group the lookup/update methods. As I only expect the list to contain 1 or 2 items in a "normal" session I didn't invest much thought into it really. I'll take a look at the example you suggest and update the patch accordingly. Thanks for the feedback, Andrew