diff options
author | pennae <github@quasiparticle.net> | 2022-01-21 14:44:00 +0100 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-01-27 17:15:43 +0100 |
commit | 41d70a2fc8d243d8c83ecc1c9ba648b625957437 (patch) | |
tree | a85c0c1971926fd8cf645f4ccf13547e2576a677 /src/libutil | |
parent | 0d7fae6a574ec1b6758a7e6d8e639145c1c465a9 (diff) |
return string_views from forceString*
once a string has been forced we already have dynamic storage allocated for it,
so we can easily reuse that storage instead of copying.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 2 | ||||
-rw-r--r-- | src/libutil/hash.hh | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 4df8b4ecb..6ed00d43c 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -259,7 +259,7 @@ Hash::Hash(std::string_view rest, HashType type, bool isSRI) throw BadHash("hash '%s' has wrong length for hash type '%s'", rest, printHashType(this->type)); } -Hash newHashAllowEmpty(std::string hashStr, std::optional<HashType> ht) +Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashType> ht) { if (hashStr.empty()) { if (!ht) diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index 1b626dd85..dff46542f 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -107,7 +107,7 @@ public: }; /* Helper that defaults empty hashes to the 0 hash. */ -Hash newHashAllowEmpty(std::string hashStr, std::optional<HashType> ht); +Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashType> ht); /* Print a hash in base-16 if it's MD5, or base-32 otherwise. */ string printHash16or32(const Hash & hash); |