Skip to content

Commit 47c16fc

Browse files
committed
SourcePath: Implement boost::hash
1 parent 8fbf4b9 commit 47c16fc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/libutil/include/nix/util/source-path.hh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,23 @@ struct SourcePath
119119

120120
std::ostream & operator<<(std::ostream & str, const SourcePath & path);
121121

122+
inline std::size_t hash_value(const SourcePath & path)
123+
{
124+
std::size_t hash = 0;
125+
boost::hash_combine(hash, path.accessor->number);
126+
boost::hash_combine(hash, path.path);
127+
return hash;
128+
}
129+
122130
} // namespace nix
123131

124132
template<>
125133
struct std::hash<nix::SourcePath>
126134
{
135+
using is_avalanching = std::true_type;
136+
127137
std::size_t operator()(const nix::SourcePath & s) const noexcept
128138
{
129-
std::size_t hash = 0;
130-
hash_combine(hash, s.accessor->number, s.path);
131-
return hash;
139+
return nix::hash_value(s);
132140
}
133141
};

0 commit comments

Comments
 (0)