Simplify parseHashTypeOpt

Remove redundant "else" after "return".

Use std::nullopt to increase readability.
This commit is contained in:
Yueh-Shun Li 2023-10-09 10:53:47 +08:00
parent 201c115c3e
commit e9ddf0b400

View file

@ -389,10 +389,10 @@ Hash compressHash(const Hash & hash, unsigned int newSize)
std::optional<HashType> parseHashTypeOpt(std::string_view s)
{
if (s == "md5") return htMD5;
else if (s == "sha1") return htSHA1;
else if (s == "sha256") return htSHA256;
else if (s == "sha512") return htSHA512;
else return std::optional<HashType> {};
if (s == "sha1") return htSHA1;
if (s == "sha256") return htSHA256;
if (s == "sha512") return htSHA512;
return std::nullopt;
}
HashType parseHashType(std::string_view s)