mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 21:16:02 +01:00
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.
This commit is contained in:
parent
0d7fae6a57
commit
41d70a2fc8
19 changed files with 94 additions and 87 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue