From e9ddf0b4008262542b422c76f60c3fb80982cd74 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Mon, 9 Oct 2023 10:53:47 +0800 Subject: [PATCH] Simplify parseHashTypeOpt Remove redundant "else" after "return". Use std::nullopt to increase readability. --- src/libutil/hash.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 2c36d9d94..6d56c1989 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -389,10 +389,10 @@ Hash compressHash(const Hash & hash, unsigned int newSize) std::optional 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 {}; + if (s == "sha1") return htSHA1; + if (s == "sha256") return htSHA256; + if (s == "sha512") return htSHA512; + return std::nullopt; } HashType parseHashType(std::string_view s)