From: Matthias Maennich <maennich@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, gprocida@google.com, kernel-team@android.com,
maennich@google.com
Subject: [PATCH] abg-dwarf-reader: simplify symbol map update
Date: Mon, 20 Apr 2020 09:43:11 +0200 [thread overview]
Message-ID: <20200420074311.92426-1-maennich@google.com> (raw)
For the update of fun_syms_, undefined_fun_syms_, var_syms_,
undefined_var_syms_, there is a pattern in
read_context::load_symbol_maps_from_symtab_section that can be
simplified: We try to find the correct entry and keep the iterator. If
we do not find it, we construct the value vector, find it again and
update the iterator. Eventually we push_back the symbol. That can be
simplified to looking up the value with operator[], which either returns
the existing value or default constructs it. The reference returned is
good for the push_back in any case.
* src/abg-dwarf-reader.cc
(read_context::load_symbol_maps_from_symtab_section): simplify
symbol map update for fun_syms_, undefined_fun_syms_, var_syms_,
undefined_var_syms_.
Signed-off-by: Matthias Maennich <maennich@google.com>
---
src/abg-dwarf-reader.cc | 46 ++++-------------------------------------
1 file changed, 4 insertions(+), 42 deletions(-)
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 333bab909901..1c0d6ea0353f 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7460,17 +7460,7 @@ public:
if (load_fun_map && symbol->is_public())
{
- {
- string_elf_symbols_map_type::iterator it =
- fun_syms_->find(symbol->get_name());
- if (it == fun_syms_->end())
- {
- (*fun_syms_)[symbol->get_name()] = elf_symbols();
- it = fun_syms_->find(symbol->get_name());
- }
- string name = symbol->get_name();
- it->second.push_back(symbol);
- }
+ (*fun_syms_)[symbol->get_name()].push_back(symbol);
{
GElf_Addr symbol_value =
@@ -7572,16 +7562,7 @@ public:
}
}
else if (load_undefined_fun_map && !symbol->is_defined())
- {
- string_elf_symbols_map_type::iterator it =
- undefined_fun_syms_->find(symbol->get_name());
- if (it == undefined_fun_syms_->end())
- {
- (*undefined_fun_syms_)[symbol->get_name()] = elf_symbols();
- it = undefined_fun_syms_->find(symbol->get_name());
- }
- it->second.push_back(symbol);
- }
+ (*undefined_fun_syms_)[symbol->get_name()].push_back(symbol);
}
else if ((load_var_map || load_undefined_var_map)
&& (GELF_ST_TYPE(sym->st_info) == STT_OBJECT
@@ -7598,17 +7579,7 @@ public:
if (load_var_map && symbol->is_public())
{
- {
- string_elf_symbols_map_type::iterator it =
- var_syms_->find(symbol->get_name());
- if (it == var_syms_->end())
- {
- (*var_syms_)[symbol->get_name()] = elf_symbols();
- it = var_syms_->find(symbol->get_name());
- }
- string name = symbol->get_name();
- it->second.push_back(symbol);
- }
+ (*var_syms_)[symbol->get_name()].push_back(symbol);
if (symbol->is_common_symbol())
{
@@ -7641,16 +7612,7 @@ public:
}
}
else if (load_undefined_var_map && !symbol->is_defined())
- {
- string_elf_symbols_map_type::iterator it =
- undefined_var_syms_->find(symbol->get_name());
- if (it == undefined_var_syms_->end())
- {
- (*undefined_var_syms_)[symbol->get_name()] = elf_symbols();
- it = undefined_var_syms_->find(symbol->get_name());
- }
- it->second.push_back(symbol);
- }
+ (*undefined_var_syms_)[symbol->get_name()].push_back(symbol);
}
}
return true;
--
2.26.1.301.g55bc3eb7cb9-goog
next reply other threads:[~2020-04-20 7:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 7:43 Matthias Maennich [this message]
2020-04-20 8:11 ` Giuliano Procida
2020-04-20 12:53 ` Dodji Seketeli
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=20200420074311.92426-1-maennich@google.com \
--to=maennich@google.com \
--cc=dodji@seketeli.org \
--cc=gprocida@google.com \
--cc=kernel-team@android.com \
--cc=libabigail@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).