diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-05 17:27:13 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-22 17:01:13 +0200 |
commit | dd23c6e397584f4bf1cf84a73d9c382a8ff81de7 (patch) | |
tree | 0f0f600a4674a03da42c07f4ea016ff3c2dc578e /src/buildtool/common/artifact_digest.hpp | |
parent | beb3faa6956b9bfd58d4ea6644a9b2987409aaba (diff) | |
download | justbuild-dd23c6e397584f4bf1cf84a73d9c382a8ff81de7.tar.gz |
Pass HashFunction to ArtifactDigest::Create
Diffstat (limited to 'src/buildtool/common/artifact_digest.hpp')
-rw-r--r-- | src/buildtool/common/artifact_digest.hpp | 10 |
1 files changed, 6 insertions, 4 deletions
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 <ObjectType kType> - [[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 <ObjectType kType> [[nodiscard]] static auto CreateFromFile( + HashFunction hash_function, std::filesystem::path const& path) noexcept -> std::optional<ArtifactDigest> { 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}; |