← Back to team overview

zorba-coders team mailing list archive

[Bug 1010051] Re: Pointless hash function in simple store

 

** Changed in: zorba
       Status: New => Fix Committed

-- 
You received this bug notification because you are a member of Zorba
Coders, which is the registrant for Zorba.
https://bugs.launchpad.net/bugs/1010051

Title:
  Pointless hash function in simple store

Status in Zorba - The XQuery Processor:
  Fix Committed

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/1010051/+subscriptions


References