Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Christian Biesinger <cbiesinger@google.com>
Cc: Tom Tromey <tromey@adacore.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/2] Avoid copying in lookup_name_info
Date: Tue, 31 Mar 2020 07:28:40 -0600	[thread overview]
Message-ID: <878sjgfybb.fsf@tromey.com> (raw)
In-Reply-To: <CAPTJ0XEsX+jOZUuOqVaJDAuC=gufXnRvAWb81pw5=jEvS92psw@mail.gmail.com> (Christian Biesinger's message of "Mon, 23 Mar 2020 12:51:32 -0500")

>>>>> "Christian" == Christian Biesinger <cbiesinger@google.com> 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


  reply	other threads:[~2020-03-31 13:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 20:49 [PATCH 0/2] Avoid copying in name lookup Tom Tromey
2020-03-20 20:49 ` [PATCH 1/2] Avoid some copying in psymtab.c Tom Tromey
2020-03-31 17:46   ` Pedro Alves
2020-03-31 19:35     ` Tom Tromey
2020-03-20 20:49 ` [PATCH 2/2] Avoid copying in lookup_name_info Tom Tromey
2020-03-23 17:51   ` Christian Biesinger
2020-03-31 13:28     ` Tom Tromey [this message]
2020-03-31 18:18   ` Pedro Alves
2020-03-31 19:11     ` Tom Tromey
2020-03-31 19:15       ` Tom Tromey
2020-03-31 19:28         ` Pedro Alves
2020-03-31 19:35           ` Tom Tromey
2020-03-31 19:23       ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sjgfybb.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=cbiesinger@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox