mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-19 07:17:00 +00:00
Speed up function_decl::get_id() and var_decl::get_id()
function_decl::get_id() var_decl::get_id() showed up high on CPU usage profiles. This patch thus implements a caching-version of these version and it incurred a 10% (at least) speed on binaries with a lot publicly exported symbols. * src/abg-ir.cc (var_decl::priv::id_): New data member. (var_decl::get_id): Cache the result on the first invocation and and returns it on subsequent invocations. (function_dec::priv::id_): New data member. (function_decl::get_id): Cache the result on the first invocation and and returns it on subsequent invocations. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
2346a328eb
commit
3afb235d0c
@ -5472,6 +5472,7 @@ struct var_decl::priv
|
||||
type_base_wptr type_;
|
||||
decl_base::binding binding_;
|
||||
elf_symbol_sptr symbol_;
|
||||
string id_;
|
||||
|
||||
priv()
|
||||
: binding_(decl_base::BINDING_GLOBAL)
|
||||
@ -5711,11 +5712,16 @@ var_decl::operator==(const decl_base& o) const
|
||||
string
|
||||
var_decl::get_id() const
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
return get_linkage_name();
|
||||
return get_pretty_representation();
|
||||
if (priv_->id_.empty())
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
priv_->id_ = s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
priv_->id_ = get_linkage_name();
|
||||
else
|
||||
priv_->id_ = get_pretty_representation();
|
||||
}
|
||||
return priv_->id_;
|
||||
}
|
||||
|
||||
/// Return the hash value for the current instance.
|
||||
@ -6320,6 +6326,7 @@ struct function_decl::priv
|
||||
decl_base::binding binding_;
|
||||
function_type_wptr type_;
|
||||
elf_symbol_sptr symbol_;
|
||||
string id_;
|
||||
|
||||
priv()
|
||||
: declared_inline_(false),
|
||||
@ -6810,11 +6817,16 @@ function_decl::get_hash() const
|
||||
string
|
||||
function_decl::get_id() const
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
return get_linkage_name();
|
||||
return get_pretty_representation();
|
||||
if (priv_->id_.empty())
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
priv_->id_ = s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
priv_->id_= get_linkage_name();
|
||||
else
|
||||
priv_->id_ = get_pretty_representation();
|
||||
}
|
||||
return priv_->id_;
|
||||
}
|
||||
|
||||
/// This implements the ir_traversable_base::traverse pure virtual
|
||||
|
Loading…
Reference in New Issue
Block a user