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

2012-06-28 Thread Matthias Brantner
** Changed in: zorba
 Assignee: Matthias Brantner (matthias-brantner) = Markos Zaharioudakis 
(markos-za)

-- 
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:
  New

Bug description:
  The implementation of XmlNode::hash() is:

uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const
{
  XmlNode* node = const_castXmlNode*(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_castuint32_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

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2012-06-07 Thread Paul J. Lucas
The implementation should also be move out-of-line, i.e., into the .cpp
file since it's a virtual function.

-- 
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:
  New

Bug description:
  The implementation of XmlNode::hash() is:

uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const
{
  XmlNode* node = const_castXmlNode*(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_castuint32_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

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp