mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Clean up PathInfo::fromJSON using recent JSON utils changes
`optionalValueAt` and then `optionalValueAt` avoids looking up twice.
This commit is contained in:
parent
37c1ef52e6
commit
089a222111
1 changed files with 10 additions and 10 deletions
|
|
@ -203,23 +203,23 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
|
|||
|
||||
// New format as this as nullable but mandatory field; handling
|
||||
// missing is for back-compat.
|
||||
if (json.contains("ca"))
|
||||
if (auto * rawCa = getNullable(valueAt(json, "ca")))
|
||||
if (auto * rawCa0 = optionalValueAt(json, "ca"))
|
||||
if (auto * rawCa = getNullable(*rawCa0))
|
||||
res.ca = ContentAddress::parse(getString(*rawCa));
|
||||
|
||||
if (json.contains("deriver"))
|
||||
if (auto * rawDeriver = getNullable(valueAt(json, "deriver")))
|
||||
if (auto * rawDeriver0 = optionalValueAt(json, "deriver"))
|
||||
if (auto * rawDeriver = getNullable(*rawDeriver0))
|
||||
res.deriver = store.parseStorePath(getString(*rawDeriver));
|
||||
|
||||
if (json.contains("registrationTime"))
|
||||
if (auto * rawRegistrationTime = getNullable(valueAt(json, "registrationTime")))
|
||||
if (auto * rawRegistrationTime0 = optionalValueAt(json, "registrationTime"))
|
||||
if (auto * rawRegistrationTime = getNullable(*rawRegistrationTime0))
|
||||
res.registrationTime = getInteger<time_t>(*rawRegistrationTime);
|
||||
|
||||
if (json.contains("ultimate"))
|
||||
res.ultimate = getBoolean(valueAt(json, "ultimate"));
|
||||
if (auto * rawUltimate = optionalValueAt(json, "ultimate"))
|
||||
res.ultimate = getBoolean(*rawUltimate);
|
||||
|
||||
if (json.contains("signatures"))
|
||||
res.sigs = getStringSet(valueAt(json, "signatures"));
|
||||
if (auto * rawSignatures = optionalValueAt(json, "signatures"))
|
||||
res.sigs = getStringSet(*rawSignatures);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue