mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
Include the accessor in the SourcePath hash
This commit is contained in:
parent
cdc23b67a6
commit
550b3479cf
2 changed files with 19 additions and 1 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include "canon-path.hh"
|
#include "canon-path.hh"
|
||||||
#include "source-accessor.hh"
|
#include "source-accessor.hh"
|
||||||
|
|
||||||
|
#include <boost/functional/hash.hpp> // for boost::hash_combine
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,6 +130,8 @@ struct std::hash<nix::SourcePath>
|
||||||
{
|
{
|
||||||
std::size_t operator()(const nix::SourcePath & s) const noexcept
|
std::size_t operator()(const nix::SourcePath & s) const noexcept
|
||||||
{
|
{
|
||||||
return std::hash<decltype(s.path)>{}(s.path);
|
std::size_t hash = 0;
|
||||||
|
hash_combine(hash, s.accessor->number, s.path);
|
||||||
|
return hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -360,4 +360,18 @@ inline std::string operator + (std::string_view s1, const char * s2)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash_combine() from Boost. Hash several hashable values together
|
||||||
|
* into a single hash.
|
||||||
|
*/
|
||||||
|
inline void hash_combine(std::size_t & seed) { }
|
||||||
|
|
||||||
|
template <typename T, typename... Rest>
|
||||||
|
inline void hash_combine(std::size_t & seed, const T & v, Rest... rest)
|
||||||
|
{
|
||||||
|
std::hash<T> hasher;
|
||||||
|
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||||
|
hash_combine(seed, rest...);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue