Skip to content

Commit

Permalink
Simplify parseHashTypeOpt
Browse files Browse the repository at this point in the history
Remove redundant "else" after "return".

Use std::nullopt to increase readability.
  • Loading branch information
ShamrockLee committed Oct 18, 2023
1 parent 201c115 commit e9ddf0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libutil/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9ddf0b

Please sign in to comment.