← Back to team overview

linuxdcpp-team team mailing list archive

[Bug 1193899] [NEW] Incorrect hasher for class CID.

 

Public bug reported:

Please replace the incorrect class hasher CID, on hasher, taking into
account all the data, and as a consequence. eliminating collisions. This
change will increase the efficiency of search hashing.

#include <boost/functional/hash.hpp>

class CID
{
...
		size_t toHash() const
		{
			return boost::hash<uint8_t[SIZE]>()(cid);
		}
...
};

namespace std
{
template<>
struct hash<CID>
{
	size_t operator()(const CID& rhs) const
	{
		return rhs.toHash();
	}
};

template<>
struct hash<CID*>
{
	size_t operator()(const CID* rhs) const
	{
		return rhs->toHash();
	}
};

...

}

Original commit from FlylinkDC++:
https://code.google.com/p/flylinkdc/source/detail?r=14282 and
https://code.google.com/p/flylinkdc/source/detail?r=14283

** Affects: dcplusplus
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of
Dcplusplus-team, which is subscribed to DC++.
https://bugs.launchpad.net/bugs/1193899

Title:
  Incorrect hasher for class CID.

Status in DC++:
  New

Bug description:
  Please replace the incorrect class hasher CID, on hasher, taking into
  account all the data, and as a consequence. eliminating collisions.
  This change will increase the efficiency of search hashing.

  #include <boost/functional/hash.hpp>

  class CID
  {
  ...
  		size_t toHash() const
  		{
  			return boost::hash<uint8_t[SIZE]>()(cid);
  		}
  ...
  };

  namespace std
  {
  template<>
  struct hash<CID>
  {
  	size_t operator()(const CID& rhs) const
  	{
  		return rhs.toHash();
  	}
  };

  template<>
  struct hash<CID*>
  {
  	size_t operator()(const CID* rhs) const
  	{
  		return rhs->toHash();
  	}
  };

  ...

  }

  Original commit from FlylinkDC++:
  https://code.google.com/p/flylinkdc/source/detail?r=14282 and
  https://code.google.com/p/flylinkdc/source/detail?r=14283

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


Follow ups

References