From ba8ecf46a1e5b7b0f4738adc31eab0f6b6d2b00c Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 13 Feb 2015 20:39:44 +0100 Subject: [PATCH] Do not apply diff filters sub-tree not carrying changes Some *huge* sub-trees might not carry any change. In that case do not bother applying the filter because eventually no filter is going to be applied anyway. This can save us a lot of walking time. * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Do not try to do the categorizing on a diff sub-tree that does not carry any change. * src/abg-comparison.cc (diff_context::maybe_apply_filters): Do not bother trying to apply the filters on a diff sub-tree that does not carry any change. Signed-off-by: Dodji Seketeli --- src/abg-comp-filter.cc | 6 ++++++ src/abg-comparison.cc | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/abg-comp-filter.cc b/src/abg-comp-filter.cc index eb194a86..6269c298 100644 --- a/src/abg-comp-filter.cc +++ b/src/abg-comp-filter.cc @@ -670,6 +670,9 @@ has_harmful_enum_change(const diff* diff) bool harmless_filter::visit(diff* d, bool pre) { + if (!d->has_changes()) + return true; + diff_category category = NO_CHANGE_CATEGORY; if (pre) @@ -721,6 +724,9 @@ harmful_filter::visit(diff* d, bool pre) { diff_category category = NO_CHANGE_CATEGORY; + if (!d->has_changes()) + return true; + if (pre) { decl_base_sptr f = d->first_subject(), diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index b3f61249..ae2c10e1 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -2710,6 +2710,9 @@ diff_context::maybe_apply_filters(diff_sptr diff, if (get_allowed_category() == EVERYTHING_CATEGORY) return; + if (!diff->has_changes()) + return; + bool s = visiting_a_node_twice_is_forbidden(); if (!visit_nodes_once) forbid_visiting_a_node_twice(false); @@ -2738,6 +2741,10 @@ void diff_context::maybe_apply_filters(corpus_diff_sptr diff, bool visit_nodes_once) { + + if (!diff || !diff->has_changes()) + return; + bool s = visiting_a_node_twice_is_forbidden(); if (!visit_nodes_once) forbid_visiting_a_node_twice(false);