Browse Source

Merge pull request #11933 from Chocobo1/qhash

Improve qHash functions
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
4884788c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/base/bittorrent/infohash.cpp
  2. 2
      src/base/bittorrent/torrenthandle.cpp
  3. 2
      src/base/bittorrent/trackerentry.cpp
  4. 2
      src/base/net/downloadmanager.cpp

4
src/base/bittorrent/infohash.cpp

@ -89,5 +89,9 @@ bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right) @@ -89,5 +89,9 @@ bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right)
uint BitTorrent::qHash(const InfoHash &key, const uint seed)
{
#if (LIBTORRENT_VERSION_NUM < 10200)
return ::qHash(static_cast<QString>(key), seed);
#else
return ::qHash((std::hash<lt::sha1_hash> {})(key), seed);
#endif
}

2
src/base/bittorrent/torrenthandle.cpp

@ -82,7 +82,7 @@ namespace libtorrent @@ -82,7 +82,7 @@ namespace libtorrent
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed)
{
return static_cast<uint>((std::hash<strong_typedef<T, Tag>> {})(key) ^ seed);
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
}
}
}

2
src/base/bittorrent/trackerentry.cpp

@ -162,5 +162,5 @@ bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right) @@ -162,5 +162,5 @@ bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
uint BitTorrent::qHash(const TrackerEntry &key, const uint seed)
{
return (::qHash(key.url(), seed) ^ key.tier());
return (::qHash(key.url(), seed) ^ ::qHash(key.tier()));
}

2
src/base/net/downloadmanager.cpp

@ -348,7 +348,7 @@ Net::ServiceID Net::ServiceID::fromURL(const QUrl &url) @@ -348,7 +348,7 @@ Net::ServiceID Net::ServiceID::fromURL(const QUrl &url)
uint Net::qHash(const ServiceID &serviceID, const uint seed)
{
return ::qHash(serviceID.hostName, seed) ^ serviceID.port;
return ::qHash(serviceID.hostName, seed) ^ ::qHash(serviceID.port);
}
bool Net::operator==(const ServiceID &lhs, const ServiceID &rhs)

Loading…
Cancel
Save