diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-17 12:57:28 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-22 17:02:34 +0200 |
commit | b2f51059cc034f03c70df28a5597a591ed3e5c5d (patch) | |
tree | fa607f601f623f70a05aabc18801c6daed4c2a18 /src/buildtool/crypto/hash_function.hpp | |
parent | 0b80611163ffedb87dc2305320906f27e502cbcd (diff) | |
download | justbuild-b2f51059cc034f03c70df28a5597a591ed3e5c5d.tar.gz |
Create Hasher using a static function
Diffstat (limited to 'src/buildtool/crypto/hash_function.hpp')
-rw-r--r-- | src/buildtool/crypto/hash_function.hpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/buildtool/crypto/hash_function.hpp b/src/buildtool/crypto/hash_function.hpp index c73458eb..99a15cdb 100644 --- a/src/buildtool/crypto/hash_function.hpp +++ b/src/buildtool/crypto/hash_function.hpp @@ -69,13 +69,17 @@ class HashFunction { /// \brief Obtain incremental hasher for computing plain hashes. [[nodiscard]] auto MakeHasher() const noexcept -> Hasher { + std::optional<Hasher> hasher; switch (type_) { case JustHash::Native: - return Hasher{Hasher::HashType::SHA1}; + hasher = Hasher::Create(Hasher::HashType::SHA1); + break; case JustHash::Compatible: - return Hasher{Hasher::HashType::SHA256}; + hasher = Hasher::Create(Hasher::HashType::SHA256); + break; } - Ensures(false); // unreachable + Ensures(hasher.has_value()); + return *std::move(hasher); } private: |