mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Avoid redundant hashing
The return type of `std::hash()` is larger (or equal) than what `qHash()` requires so we can omit hashing it again.
This commit is contained in:
@@ -131,12 +131,16 @@ bool operator<(const Digest32<N> &left, const Digest32<N> &right)
|
||||
< static_cast<typename Digest32<N>::UnderlyingType>(right);
|
||||
}
|
||||
|
||||
template <int N>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
template <int N>
|
||||
std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0)
|
||||
#else
|
||||
uint qHash(const Digest32<N> &key, const uint seed = 0)
|
||||
#endif
|
||||
{
|
||||
return ::qHash(std::hash<typename Digest32<N>::UnderlyingType>()(key), seed);
|
||||
return ::qHash(static_cast<typename Digest32<N>::UnderlyingType>(key), seed);
|
||||
}
|
||||
#else
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user