[v2,05/11] gdb: simplify insertion in global_symbol_searcher::add_matching_symbols
Commit Message
From: Simon Marchi <simon.marchi@efficios.com>
std::set::insert does nothing if an equivalent element is already
in the set, so checking with find first is redundant. Replace find+insert
with emplace.
Change-Id: I869284407cfefb9b2d7ad7305fe04fbdaee25f1f
Reviewed-By: Rohr, Stephan <stephan.rohr@intel.com>
---
gdb/symtab.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Comments
simon.marchi@polymtl.ca writes:
> From: Simon Marchi <simon.marchi@efficios.com>
>
> std::set::insert does nothing if an equivalent element is already
> in the set, so checking with find first is redundant. Replace find+insert
> with emplace.
LGTM.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
@@ -4878,13 +4878,9 @@ global_symbol_searcher::add_matching_symbols
if (sym->domain () == MODULE_DOMAIN && sym->line () == 0)
continue;
+ /* Match, insert if not already in the results. */
if (result_set->size () < m_max_search_results)
- {
- /* Match, insert if not already in the results. */
- symbol_search ss (block, sym);
- if (result_set->find (ss) == result_set->end ())
- result_set->insert (ss);
- }
+ result_set->emplace (block, sym);
else
return false;
}