]> sourceware.org Git - libabigail.git/commitdiff
Try harder to hash_type_or_decl avoid the slow path
authorDodji Seketeli <dodji@redhat.com>
Fri, 2 Oct 2015 17:57:33 +0000 (19:57 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sun, 4 Oct 2015 11:51:25 +0000 (13:51 +0200)
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>
src/abg-ir.cc

index 2625bb339cc700d4bb8146373bd2dfa1503cf91f..832cc5884c53ac2addba87c02aeb61991b6f4bf4 100644 (file)
@@ -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);
        }
This page took 0.045339 seconds and 5 git commands to generate.