aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/hash.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-02-25 16:00:00 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-02-25 16:13:02 +0100
commitdf552ff53e68dff8ca360adbdbea214ece1d08ee (patch)
tree9ed3cb700377d4731b4c234ebec16efb0099c71a /src/libutil/hash.cc
parent14b38d0887f8a8d6b75039113eface57cfb19d06 (diff)
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r--src/libutil/hash.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 6ed00d43c..a4d632161 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -66,31 +66,31 @@ bool Hash::operator < (const Hash & h) const
}
-const string base16Chars = "0123456789abcdef";
+const std::string base16Chars = "0123456789abcdef";
-static string printHash16(const Hash & hash)
+static std::string printHash16(const Hash & hash)
{
char buf[hash.hashSize * 2];
for (unsigned int i = 0; i < hash.hashSize; i++) {
buf[i * 2] = base16Chars[hash.hash[i] >> 4];
buf[i * 2 + 1] = base16Chars[hash.hash[i] & 0x0f];
}
- return string(buf, hash.hashSize * 2);
+ return std::string(buf, hash.hashSize * 2);
}
// omitted: E O U T
-const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
+const std::string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
-static string printHash32(const Hash & hash)
+static std::string printHash32(const Hash & hash)
{
assert(hash.hashSize);
size_t len = hash.base32Len();
assert(len);
- string s;
+ std::string s;
s.reserve(len);
for (int n = (int) len - 1; n >= 0; n--) {
@@ -107,7 +107,7 @@ static string printHash32(const Hash & hash)
}
-string printHash16or32(const Hash & hash)
+std::string printHash16or32(const Hash & hash)
{
assert(hash.type);
return hash.to_string(hash.type == htMD5 ? Base16 : Base32, false);
@@ -151,7 +151,8 @@ Hash Hash::parseSRI(std::string_view original) {
}
// Mutates the string to eliminate the prefixes when found
-static std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest) {
+static std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest)
+{
bool isSRI = false;
// Parse the has type before the separater, if there was one.
@@ -402,7 +403,7 @@ HashType parseHashType(std::string_view s)
throw UsageError("unknown hash algorithm '%1%'", s);
}
-string printHashType(HashType ht)
+std::string printHashType(HashType ht)
{
switch (ht) {
case htMD5: return "md5";