mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-06 22:58:01 +00:00
Try harder to hash_type_or_decl avoid the slow path
In hash_type_or_decl, when we encounter a declaration-only class (those have no canonical type), we not trying to get the canonical type of the definition, when the class had a definition. We were instead going straight to the slow path of computing the recursive hash of the type. This patch tries to get the canonical type of the class definition, when it exists. * src/abg-ir.cc (hash_type_or_decl): When a declaration-only class has a definition, then use the canonical type of that definition as a hash value. If the class no definition, only then, use the slow patfh of computing the recursive progressive hash value of the type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
8b76f6c34e
commit
4d0d387696
@ -12213,8 +12213,27 @@ hash_type_or_decl(const type_or_decl_base *tod)
|
||||
// as a hash. This is the fastest we can get.
|
||||
if (t->get_canonical_type())
|
||||
result = reinterpret_cast<size_t>(t->get_canonical_type().get());
|
||||
else if (const class_decl* cl = is_class_type(t))
|
||||
{
|
||||
if (cl->get_is_declaration_only()
|
||||
&& cl->get_definition_of_declaration())
|
||||
// The is a declaration-only class, so it has no canonical
|
||||
// type; but then it's class definition has one. Let's
|
||||
// use that one.
|
||||
return hash_type_or_decl(cl->get_definition_of_declaration());
|
||||
else
|
||||
{
|
||||
// The class really has no canonical type, let's use the
|
||||
// slow path of hashing the class recursively. Well
|
||||
// it's not that slow as the hash value is quickly going
|
||||
// to result to zero anyway.
|
||||
type_base::dynamic_hash hash;
|
||||
result = hash(t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's use the slow path of hashing the class recursively.
|
||||
type_base::dynamic_hash hash;
|
||||
result = hash(t);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user