Browse Source

Delegate string hashing to standard library

Since standard library could have platform dependent specialized hashing functions.
Also the main idea is to let `qHash` handle whatever integer type `std::hash` returns and mix it with `seed` accordingly.

PR #18715.
adaptive-webui-19844
Chocobo1 2 years ago committed by GitHub
parent
commit
a450a7c6e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/base/bittorrent/sessionimpl.cpp
  2. 2
      src/base/digest32.h

2
src/base/bittorrent/sessionimpl.cpp

@ -125,7 +125,7 @@ namespace std @@ -125,7 +125,7 @@ namespace std
{
uint qHash(const std::string &key, uint seed = 0)
{
return qHash(QByteArray::fromRawData(key.data(), static_cast<int>(key.length())), seed);
return ::qHash(std::hash<std::string> {}(key), seed);
}
}

2
src/base/digest32.h

@ -167,6 +167,6 @@ std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0) @@ -167,6 +167,6 @@ std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0)
template <int N>
uint qHash(const Digest32<N> &key, const uint seed = 0)
{
return static_cast<uint>((std::hash<typename Digest32<N>::UnderlyingType> {})(key)) ^ seed;
return ::qHash(std::hash<typename Digest32<N>::UnderlyingType> {}(key), seed);
}
#endif

Loading…
Cancel
Save