aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-04-01 07:47:13 -0600
committerTom Tromey <tromey@adacore.com>2020-04-01 07:47:13 -0600
commite0802d59969339502203ad8e0d161b5f93beca73 (patch)
tree71137374b46f6d98923a95882567c7b9f2d9b46a /gdb/language.c
parent8c072cb6a19abdc9d4b93c19a1d609fe1a486c32 (diff)
downloadgdb-e0802d59969339502203ad8e0d161b5f93beca73.zip
gdb-e0802d59969339502203ad8e0d161b5f93beca73.tar.gz
gdb-e0802d59969339502203ad8e0d161b5f93beca73.tar.bz2
Avoid copying in lookup_name_info
lookup_name_info always copies the name that is passed in. However, normally a copy is not needed. This patch changes this class to avoid copying. This required changing the "name" method to return something else; I chose a gdb::string_view, to avoid excessive calls to strlen in the code using the lookup_name_info. However, as this class does not allow an arbitrary string_view, I've also added a c_str method that guarantees a \0-terminated result -- a pedantic difference but one that respects the string_view contract, IMO. gdb/ChangeLog 2020-04-01 Tom Tromey <tromey@adacore.com> * symtab.h (class lookup_name_info) <lookup_name_info>: Change "name" parameter to rvalue reference. Initialize m_name_holder. <lookup_name_info>: New overloads. <name>: Return gdb::string_view. <c_str>: New method. <make_ignore_params>: Update. <search_name_hash>: Update. <language_lookup_name>: Return const char *. <m_name>: Change type. * symtab.c (demangle_for_lookup_info::demangle_for_lookup_info) (demangle_for_lookup_info::demangle_for_lookup_info): Update. (lookup_name_info::match_any): Update. * psymtab.c (match_partial_symbol, lookup_partial_symbol): Update. * minsyms.c (linkage_name_str): Update. * language.c (default_symbol_name_matcher): Update. * dwarf2/read.c (mapped_index_base::find_name_components_bounds): Update. * ada-lang.c (ada_fold_name): Change parameter to string_view. (ada_lookup_name_info::ada_lookup_name_info): Update. (literal_symbol_name_matcher): Update.
Diffstat (limited to 'gdb/language.c')
-rw-r--r--gdb/language.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/language.c b/gdb/language.c
index 454c6dc..c13fd1a 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -699,14 +699,14 @@ default_symbol_name_matcher (const char *symbol_search_name,
const lookup_name_info &lookup_name,
completion_match_result *comp_match_res)
{
- const std::string &name = lookup_name.name ();
+ gdb::string_view name = lookup_name.name ();
completion_match_for_lcd *match_for_lcd
= (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
strncmp_iw_mode mode = (lookup_name.completion_mode ()
? strncmp_iw_mode::NORMAL
: strncmp_iw_mode::MATCH_PARAMS);
- if (strncmp_iw_with_mode (symbol_search_name, name.c_str (), name.size (),
+ if (strncmp_iw_with_mode (symbol_search_name, name.data (), name.size (),
mode, language_minimal, match_for_lcd) == 0)
{
if (comp_match_res != NULL)