Get rid of the std::pair

This commit is contained in:
Carlo Nucera 2020-07-02 11:09:04 -04:00
parent 27c8029573
commit f61bc45d19
2 changed files with 5 additions and 7 deletions
src/libutil

View file

@ -141,7 +141,7 @@ Hash Hash::fromSRI(std::string_view original) {
throw BadHash("hash '%s' is not SRI", original); throw BadHash("hash '%s' is not SRI", original);
HashType parsedType = parseHashType(*hashRaw); HashType parsedType = parseHashType(*hashRaw);
return Hash(rest, std::make_pair(parsedType, true)); return Hash(rest, parsedType, true);
} }
Hash Hash::parseAnyPrefixed(std::string_view s) Hash Hash::parseAnyPrefixed(std::string_view s)
@ -178,14 +178,12 @@ Hash Hash::parseAny(std::string_view original, std::optional<HashType> optType)
throw BadHash("hash '%s' should have type '%s'", original, printHashType(*optType)); throw BadHash("hash '%s' should have type '%s'", original, printHashType(*optType));
hashType = optParsedType ? *optParsedType : *optType; hashType = optParsedType ? *optParsedType : *optType;
return Hash(rest, std::make_pair(hashType, isSRI)); return Hash(rest, hashType, isSRI);
} }
Hash::Hash(std::string_view rest, std::pair<HashType, bool> typeAndSRI) Hash::Hash(std::string_view rest, HashType type, bool isSRI)
: Hash(typeAndSRI.first) : Hash(type)
{ {
auto [type, isSRI] = std::move(typeAndSRI);
if (!isSRI && rest.size() == base16Len()) { if (!isSRI && rest.size() == base16Len()) {
auto parseHexDigit = [&](char c) { auto parseHexDigit = [&](char c) {

View file

@ -49,7 +49,7 @@ struct Hash
private: private:
// type must be provided, s must not include <type> prefix // type must be provided, s must not include <type> prefix
Hash(std::string_view s, std::pair<HashType, bool> typeAndSRI); Hash(std::string_view s, HashType type, bool isSRI);
public: public:
/* Check whether a hash is set. */ /* Check whether a hash is set. */