From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11618 invoked by alias); 24 Jan 2020 19:14:08 -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 11607 invoked by uid 89); 24 Jan 2020 19:14:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=lowest X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.70.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 19:14:06 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 8C47D400C40FF for ; Fri, 24 Jan 2020 11:41:25 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id v45jilqQ5ERZgv45jidQbZ; Fri, 24 Jan 2020 12:54:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0lXlFO9cGXqtVOF7eyfdrWW+LgpJKyewTUS6HjSlQj8=; b=MaSNjdFz36QJC5nHwELXQOItpp 1DdFIWUiuZINnFlcFSekSfioN3Bzt1ckiEGsf+CULTohq7cxPzY2iN8QvnBsKu4Ff6HsFJlLxcLbV By3TRpRpJ30OxG92vAkJwxL7U; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:34378 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iv45j-000Ks4-P0; Fri, 24 Jan 2020 11:54:03 -0700 From: Tom Tromey To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] gdb: Convert completion tracker to use std types References: Date: Fri, 24 Jan 2020 19:18:00 -0000 In-Reply-To: (Andrew Burgess's message of "Fri, 27 Dec 2019 21:32:26 +0000") Message-ID: <87pnf88z3o.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2020-01/txt/msg00826.txt.bz2 >>>>> "Andrew" == Andrew Burgess writes: Andrew> For now then I'm holding the raw 'char *' within the unordered_map, Andrew> and rely on the completion_tracker object to delete the data if Andrew> needed, or to ensure that the data is passed over to readline, which Andrew> will do the deletion for us. Seems reasonable enough. Andrew> + for (const auto &p : m_entries_hash) Andrew> + { Andrew> + xfree ((char *) p.first); Andrew> + xfree ((char *) p.second); Maybe const_cast would be better? Andrew> + /* A map of completions. The key is the completion, and the value is the Andrew> + string to be used to compute the lowest common denominator. Both the Andrew> + key and the value are owned by the completion_tracker class while Andrew> + being held in this map, as such completion_tracker must free these Andrew> + strings when finished with them, or pass ownership to someone else who Andrew> + will free them. */ Andrew> + typedef std::unordered_map, Andrew> + std::equal_to> completion_set; Does using std::string here mean that a temporary std::string will be made for each insertion in the map? And also for comparisons? That seems expensive if so. Tom