aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/hash.cc
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-07-01 18:34:18 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-07-01 18:34:18 -0400
commit263ccdd48923b730fd7e6f687583160d7b24039b (patch)
tree156305c1928adae6f67ff1aacd2c55a0a0097a24 /src/libutil/hash.cc
parentc8c4bcf90e065b47c3ee2984b1f8ff696da889af (diff)
Rename two hash constructors to proper functions
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r--src/libutil/hash.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 2087e3464..fcc0b9eb7 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -144,7 +144,10 @@ Hash Hash::fromSRI(std::string_view original) {
return Hash(rest, std::make_pair(parsedType, true));
}
-Hash::Hash(std::string_view s) : Hash(s, std::nullopt) {}
+Hash Hash::parseAnyPrefixed(std::string_view s)
+{
+ return parseAny(s, std::nullopt);
+}
static std::pair<HashType, bool> newFunction(std::string_view & original, std::optional<HashType> optType)
{
@@ -181,8 +184,11 @@ static std::pair<HashType, bool> newFunction(std::string_view & original, std::o
}
// mutates the string_view
-Hash::Hash(std::string_view original, std::optional<HashType> optType)
- : Hash(original, newFunction(original, optType)) {}
+Hash Hash::parseAny(std::string_view original, std::optional<HashType> optType)
+{
+ auto typeAndSRI = newFunction(original, optType);
+ return Hash(original, typeAndSRI);
+}
Hash::Hash(std::string_view rest, std::pair<HashType, bool> typeAndSRI)
: Hash(typeAndSRI.first)
@@ -249,7 +255,7 @@ Hash newHashAllowEmpty(std::string hashStr, std::optional<HashType> ht)
warn("found empty hash, assuming '%s'", h.to_string(SRI, true));
return h;
} else
- return Hash(hashStr, ht);
+ return Hash::parseAny(hashStr, ht);
}