From 6a1a136764f2defb6e220192f7963238fc940209 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 15 Oct 2009 20:50:34 -0700 Subject: [PATCH] Let a tracker do negative caching in dwarf_comparator. --- libdw/ChangeLog | 5 +++++ libdw/c++/dwarf_comparator | 21 +++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 9fd6794ed..c8bbab65d 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2009-10-15 Roland McGrath + + * c++/dwarf_comparator (dwarf_comparator::reference_match): + Don't bail out before calling tracker's notice_match on mismatches. + 2009-10-02 Roland McGrath * c++/subr.hh (subr::stackish): New template type. diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index b9bf317f0..1fe062c8c 100644 --- a/libdw/c++/dwarf_comparator +++ b/libdw/c++/dwarf_comparator @@ -517,10 +517,12 @@ namespace elfutils const typename tracker::right_context_type &rhs = _m_tracker.right_context (ref2); + bool result = true; + /* First do the cheap mismatch check on the contexts, then check the contents and contexts in ascending order of costliness of a check. */ if (_m_tracker.context_quick_mismatch (lhs, rhs)) - return nomatch (a, b, "quick context"); + result = nomatch (a, b, "quick context"); /* To compare the children, we have to clone the tracker and use a new one, in case of any reference attributes in their subtrees. @@ -533,19 +535,14 @@ namespace elfutils typename tracker::subtracker t (_m_tracker, matched, lhs, rhs); subcomparator cmp (t); - if (!cmp.equals (a.attributes (), b.attributes ())) - return nomatch (a, b, "attribute"); + if (result && !cmp.equals (a.attributes (), b.attributes ())) + result = nomatch (a, b, "attribute"); - if (!_m_tracker.context_match (lhs, rhs)) - return nomatch (a, b, "context"); + if (result && !_m_tracker.context_match (lhs, rhs)) + result = nomatch (a, b, "context"); - bool result = !has_children; - if (has_children) - { - result = cmp.equals (a.children (), b.children ()); - if (!result) - result = nomatch (a, b, "children"); - } + if (result && has_children && !cmp.equals (a.children (), b.children ())) + result = nomatch (a, b, "children"); // Let the tracker cache a result for its reference_matched. return _m_tracker.notice_match (matched, ref1, ref2, result); -- 2.47.3