1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 13:06:01 +01:00

Remove some pointless std::visit

These are not needed, because the `toJSON` methods are already
implemented for the variant wrapper too.
This commit is contained in:
John Ericson 2025-09-23 13:58:02 -04:00
parent d9de675357
commit 1c71cb4005

View file

@ -12,7 +12,7 @@ static nlohmann::json derivedPathsToJSON(const DerivedPaths & paths, Store & sto
{
auto res = nlohmann::json::array();
for (auto & t : paths) {
std::visit([&](const auto & t) { res.push_back(t.toJSON(store)); }, t.raw());
res.push_back(t.toJSON(store));
}
return res;
}
@ -22,22 +22,18 @@ builtPathsWithResultToJSON(const std::vector<BuiltPathWithResult> & buildables,
{
auto res = nlohmann::json::array();
for (auto & b : buildables) {
std::visit(
[&](const auto & t) {
auto j = t.toJSON(store);
if (b.result) {
if (b.result->startTime)
j["startTime"] = b.result->startTime;
if (b.result->stopTime)
j["stopTime"] = b.result->stopTime;
if (b.result->cpuUser)
j["cpuUser"] = ((double) b.result->cpuUser->count()) / 1000000;
if (b.result->cpuSystem)
j["cpuSystem"] = ((double) b.result->cpuSystem->count()) / 1000000;
}
res.push_back(j);
},
b.path.raw());
auto j = b.path.toJSON(store);
if (b.result) {
if (b.result->startTime)
j["startTime"] = b.result->startTime;
if (b.result->stopTime)
j["stopTime"] = b.result->stopTime;
if (b.result->cpuUser)
j["cpuUser"] = ((double) b.result->cpuUser->count()) / 1000000;
if (b.result->cpuSystem)
j["cpuSystem"] = ((double) b.result->cpuSystem->count()) / 1000000;
}
res.push_back(j);
}
return res;
}