From b2f51059cc034f03c70df28a5597a591ed3e5c5d Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 17 Jul 2024 12:57:28 +0200 Subject: Create Hasher using a static function --- src/buildtool/crypto/hash_function.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/buildtool/crypto/hash_function.hpp') 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; 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: -- cgit v1.2.3