diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-04 20:42:02 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-04 20:42:02 +0000 |
commit | ed86acf02aa5810044b995dc57744d7b51867bb0 (patch) | |
tree | 380214d464bc592619ed28b0a48956f278ff0cc4 | |
parent | 574d5460f02c46e9e5bcca93a14ccf782cb2c8f8 (diff) |
Use some `std::optional::has_value` for clarity
-rw-r--r-- | src/libstore/local-store.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index af6c6f390..804d4c514 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -576,7 +576,7 @@ void LocalStore::checkDerivationOutputs(const StorePath & drvPath, const Derivat uint64_t LocalStore::addValidPath(State & state, const ValidPathInfo & info, bool checkOutputs) { - if (info.ca && !info.isContentAddressed(*this)) + if (info.ca.has_value() && !info.isContentAddressed(*this)) throw Error("cannot add path '%s' to the Nix store because it claims to be content-addressed but isn't", printStorePath(info.path)); @@ -1001,13 +1001,13 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source, // text hashing has long been allowed to have non-self-references because it is used for drv files. bool refersToSelf = info.references.count(info.path) > 0; - if (info.ca && !info.references.empty() && !(std::holds_alternative<TextHash>(*info.ca) && !refersToSelf)) + if (info.ca.has_value() && !info.references.empty() && !(std::holds_alternative<TextHash>(*info.ca) && !refersToSelf)) settings.requireExperimentalFeature("ca-references"); /* While restoring the path from the NAR, compute the hash of the NAR. */ std::unique_ptr<AbstractHashSink> hashSink; - if (info.ca || !info.references.count(info.path)) + if (info.ca.has_value() || !info.references.count(info.path)) hashSink = std::make_unique<HashSink>(HashType::SHA256); else hashSink = std::make_unique<HashModuloSink>(HashType::SHA256, storePathToHash(printStorePath(info.path))); |