From: Mark Wielaard Date: Fri, 21 Jan 2011 21:44:15 +0000 (+0100) Subject: Add local hash for children_types. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd305fc58957c861dd62754913df689f3b75e72e;p=thirdparty%2Felfutils.git Add local hash for children_types. --- diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 2c68cbe27..04ace9646 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -246,12 +246,17 @@ namespace elfutils typedef std::vector _base; size_t _m_hash; + size_t _m_local_hash; inline void set_hash () { _m_hash = 0; + _m_local_hash = 0; for (_base::iterator i = _base::begin (); i != _base::end (); ++i) - subr::hash_combine (_m_hash, (uintptr_t) *i); + { + subr::hash_combine (_m_hash, (uintptr_t) *i); + subr::hash_combine (_m_local_hash, (*i)->first.local_hash ()); + } } inline children_type () {} @@ -293,6 +298,7 @@ namespace elfutils inline bool is (const children_type &these) const { return (_m_hash == these._m_hash + && _m_local_hash == these._m_local_hash && size () == these.size () && std::equal (_base::begin (), _base::end (), these._base::begin ())); @@ -311,6 +317,11 @@ namespace elfutils { return const_iterator (_base::end (), subr::nothing ()); } + + inline size_t local_hash () const + { + return _m_local_hash; + } }; typedef children_type::iterator pointer; @@ -418,7 +429,7 @@ namespace elfutils { size_t hash = _m_tag; subr::hash_combine (hash, _m_attributes->local_hash ()); - subr::hash_combine (hash, _m_children->size ()); + subr::hash_combine (hash, _m_children->local_hash ()); return hash; } }; @@ -1499,7 +1510,15 @@ namespace elfutils attr_hash ^= (it->first << 3); } subr::hash_combine (hash, attr_hash); - subr::hash_combine (hash, _m_children.size ()); + + size_t children_hash = 0; + for (typename std::vector::const_iterator it + = _m_children.begin (); + it != _m_children.end (); + ++it) + subr::hash_combine (children_hash, (*it)->local_hash ()); + subr::hash_combine (hash, children_hash); + return hash; } };