From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 8B6C9385B836 for ; Tue, 31 Mar 2020 13:28:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B6C9385B836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 55D56116D3A; Tue, 31 Mar 2020 09:28:41 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mM9-E1bzNxEV; Tue, 31 Mar 2020 09:28:41 -0400 (EDT) Received: from murgatroyd (97-118-117-21.hlrn.qwest.net [97.118.117.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id EA385116C57; Tue, 31 Mar 2020 09:28:40 -0400 (EDT) From: Tom Tromey To: Christian Biesinger Cc: Tom Tromey , gdb-patches Subject: Re: [PATCH 2/2] Avoid copying in lookup_name_info References: <20200320204935.19509-1-tromey@adacore.com> <20200320204935.19509-3-tromey@adacore.com> X-Attribution: Tom Date: Tue, 31 Mar 2020 07:28:40 -0600 In-Reply-To: (Christian Biesinger's message of "Mon, 23 Mar 2020 12:51:32 -0500") Message-ID: <878sjgfybb.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 13:28:42 -0000 >>>>> "Christian" == Christian Biesinger writes: >> int cmp = (lookup_name.completion_mode () >> - ? strncmp (symbol_search_name, name.c_str (), name.size ()) >> - : strcmp (symbol_search_name, name.c_str ())); >> + ? strncmp (symbol_search_name, name, name_view.size ()) >> + : strcmp (symbol_search_name, name)); Christian> You can just use symbol_search_name == name_view, since Christian> gdb::string_view has an overloaded operator==. That way you don't need Christian> to call c_str() here. Thanks, I made this change. I removed "cmp" as well, so now it looks like: if (lookup_name.completion_mode () ? (strncmp (symbol_search_name, name_view.data (), name_view.size ()) == 0) : symbol_search_name == name_view) C++20 has a starts_with method on string view, but we don't have that yet. Tom