From dd23c6e397584f4bf1cf84a73d9c382a8ff81de7 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 5 Jul 2024 17:27:13 +0200 Subject: Pass HashFunction to ArtifactDigest::Create --- src/buildtool/common/artifact_digest.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/buildtool/common/artifact_digest.hpp') diff --git a/src/buildtool/common/artifact_digest.hpp b/src/buildtool/common/artifact_digest.hpp index 59299232..686a6fa5 100644 --- a/src/buildtool/common/artifact_digest.hpp +++ b/src/buildtool/common/artifact_digest.hpp @@ -74,17 +74,18 @@ class ArtifactDigest { } template - [[nodiscard]] static auto Create(std::string const& content) noexcept + [[nodiscard]] static auto Create(HashFunction hash_function, + std::string const& content) noexcept -> ArtifactDigest { if constexpr (kType == ObjectType::Tree) { return ArtifactDigest{ - HashFunction::Instance().ComputeTreeHash(content).HexString(), + hash_function.ComputeTreeHash(content).HexString(), content.size(), /*is_tree=*/true}; } else { return ArtifactDigest{ - HashFunction::Instance().ComputeBlobHash(content).HexString(), + hash_function.ComputeBlobHash(content).HexString(), content.size(), /*is_tree=*/false}; } @@ -92,10 +93,11 @@ class ArtifactDigest { template [[nodiscard]] static auto CreateFromFile( + HashFunction hash_function, std::filesystem::path const& path) noexcept -> std::optional { static constexpr bool kIsTree = IsTreeObject(kType); - auto hash = HashFunction::Instance().ComputeHashFile(path, kIsTree); + auto hash = hash_function.ComputeHashFile(path, kIsTree); if (hash) { return ArtifactDigest{ hash->first.HexString(), hash->second, kIsTree}; -- cgit v1.2.3