aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/path.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/path.cc')
-rw-r--r--src/libstore/path.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstore/path.cc b/src/libstore/path.cc
index d4b5fc0dc..82ed20285 100644
--- a/src/libstore/path.cc
+++ b/src/libstore/path.cc
@@ -112,3 +112,13 @@ PathSet Store::printStorePathSet(const StorePathSet & paths) const
}
}
+
+std::size_t std::hash<nix::StorePath>::operator()(const nix::StorePath & path) const noexcept
+{
+ // It's already a cryptographic hash of 160 bits (assuming that nobody gives us bogus ones...), so just parse it.
+ auto h = nix::Hash::parseNonSRIUnprefixed(path.hashPart(), nix::HashType::SHA1);
+ // This need not be stable across machines, so bit casting the start of it is fine.
+ size_t r;
+ memcpy(&r, h.hash, sizeof(r));
+ return r;
+}