aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.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/symtab.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/symtab.c')
-rw-r--r--gdb/symtab.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f300d75..6802801 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1790,7 +1790,7 @@ demangle_for_lookup_info::demangle_for_lookup_info
if (lookup_name.ignore_parameters () && lang == language_cplus)
{
gdb::unique_xmalloc_ptr<char> without_params
- = cp_remove_params_if_any (lookup_name.name ().c_str (),
+ = cp_remove_params_if_any (lookup_name.c_str (),
lookup_name.completion_mode ());
if (without_params != NULL)
@@ -1803,9 +1803,9 @@ demangle_for_lookup_info::demangle_for_lookup_info
}
if (lookup_name.match_type () == symbol_name_match_type::SEARCH_NAME)
- m_demangled_name = lookup_name.name ();
+ m_demangled_name = lookup_name.c_str ();
else
- m_demangled_name = demangle_for_lookup (lookup_name.name ().c_str (),
+ m_demangled_name = demangle_for_lookup (lookup_name.c_str (),
lang, storage);
}
@@ -1816,7 +1816,7 @@ lookup_name_info::match_any ()
{
/* Lookup any symbol that "" would complete. I.e., this matches all
symbol names. */
- static const lookup_name_info lookup_name ({}, symbol_name_match_type::FULL,
+ static const lookup_name_info lookup_name ("", symbol_name_match_type::FULL,
true);
return lookup_name;