Speedup comparison of decl-only classes
authorDodji Seketeli <dodji@redhat.com>
Thu, 6 Apr 2017 10:49:17 +0000 (12:49 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 10 May 2017 09:48:01 +0000 (11:48 +0200)
Profiling shows that while writting out the abixml for a big
corpus_group, comparing decl-only classes is a hot spot.

This patch avoids calling the function
class_or_union::priv_->comparison_started (which appears to be
culprit) in that case.

This makes writting out the abixml of the corpus_group of the Linux
kernel be ~20% faster.

* src/abg-ir.cc (equals): In the overload for class_decl, if we
are looking at a decl-only class, then directly call the equals
function for class_or_union.  That one knows how to perform the
comparison without calling the
class_or_union::priv_->comparison_started function, in that case.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc

index e06fa6e608db4e33548678f064db8618f385b1d0..ec1ace140eb2ca7346ec2a183b1ab52bbf33b5fa 100644 (file)
@@ -16641,6 +16641,13 @@ method_matches_at_least_one_in_vector(const method_decl_sptr& method,
 bool
 equals(const class_decl& l, const class_decl& r, change_kind* k)
 {
+  // if one of the classes is declaration-only then we take a fast
+  // path here.
+  if (l.get_is_declaration_only() || r.get_is_declaration_only())
+    return equals(static_cast<const class_or_union&>(l),
+                 static_cast<const class_or_union&>(r),
+                 k);
+
   if (l.class_or_union::priv_->comparison_started(l)
       || l.class_or_union::priv_->comparison_started(r))
     return true;
@@ -16655,12 +16662,6 @@ equals(const class_decl& l, const class_decl& r, change_kind* k)
        return result;
     }
 
-  // if one of the classes is declaration-only then we are done.
-  bool l_is_decl_only = l.get_is_declaration_only();
-  bool r_is_decl_only = r.get_is_declaration_only();
-  if (l_is_decl_only || r_is_decl_only)
-    return result;
-
   l.class_or_union::priv_->mark_as_being_compared(l);
   l.class_or_union::priv_->mark_as_being_compared(r);