Pointless hash function in simple store

Bug #1010051 reported by Paul J. Lucas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Low
Markos Zaharioudakis

Bug Description

The implementation of XmlNode::hash() is:

  uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const
  {
    XmlNode* node = const_cast<XmlNode*>(this);
    return hashfun::h32((void*)(&node), sizeof(node), FNV_32_INIT);
  }

Computing the hash of a pointer is pointless -- just cast the pointer:

  uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const
  {
    return reinterpret_cast<uint32_t>( this );
  }

Indeed, the std::hash() function in C++11 for T* does exactly this.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

The implementation should also be move out-of-line, i.e., into the .cpp file since it's a virtual function.

Changed in zorba:
assignee: nobody → Matthias Brantner (matthias-brantner)
Changed in zorba:
assignee: Matthias Brantner (matthias-brantner) → Markos Zaharioudakis (markos-za)
Changed in zorba:
status: New → Fix Committed
Changed in zorba:
milestone: none → 2.6
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.