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

Merge pull request #14054 from obsidiansystems/to-json-no-copy

Fix `JSON_IMPL` macro to avoid extraneous copies
This commit is contained in:
Eelco Dolstra 2025-09-23 20:58:12 +02:00 committed by GitHub
commit 73d3ab05b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 17 additions and 17 deletions

View file

@ -509,7 +509,7 @@ fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json &
return res;
}
void adl_serializer<fetchers::PublicKey>::to_json(json & json, fetchers::PublicKey p)
void adl_serializer<fetchers::PublicKey>::to_json(json & json, const fetchers::PublicKey & p)
{
json["type"] = p.type;
json["key"] = p.key;

View file

@ -356,7 +356,7 @@ DerivationOptions adl_serializer<DerivationOptions>::from_json(const json & json
};
}
void adl_serializer<DerivationOptions>::to_json(json & json, DerivationOptions o)
void adl_serializer<DerivationOptions>::to_json(json & json, const DerivationOptions & o)
{
json["outputChecks"] = std::visit(
overloaded{
@ -398,7 +398,7 @@ DerivationOptions::OutputChecks adl_serializer<DerivationOptions::OutputChecks>:
};
}
void adl_serializer<DerivationOptions::OutputChecks>::to_json(json & json, DerivationOptions::OutputChecks c)
void adl_serializer<DerivationOptions::OutputChecks>::to_json(json & json, const DerivationOptions::OutputChecks & c)
{
json["ignoreSelfRefs"] = c.ignoreSelfRefs;
json["allowedReferences"] = c.allowedReferences;

View file

@ -1494,7 +1494,7 @@ Derivation adl_serializer<Derivation>::from_json(const json & json)
return Derivation::fromJSON(json);
}
void adl_serializer<Derivation>::to_json(json & json, Derivation c)
void adl_serializer<Derivation>::to_json(json & json, const Derivation & c)
{
json = c.toJSON();
}

View file

@ -150,7 +150,7 @@ OutputsSpec adl_serializer<OutputsSpec>::from_json(const json & json)
return OutputsSpec::Names{std::move(names)};
}
void adl_serializer<OutputsSpec>::to_json(json & json, OutputsSpec t)
void adl_serializer<OutputsSpec>::to_json(json & json, const OutputsSpec & t)
{
std::visit(
overloaded{
@ -169,7 +169,7 @@ ExtendedOutputsSpec adl_serializer<ExtendedOutputsSpec>::from_json(const json &
}
}
void adl_serializer<ExtendedOutputsSpec>::to_json(json & json, ExtendedOutputsSpec t)
void adl_serializer<ExtendedOutputsSpec>::to_json(json & json, const ExtendedOutputsSpec & t)
{
std::visit(
overloaded{

View file

@ -88,7 +88,7 @@ StorePath adl_serializer<StorePath>::from_json(const json & json)
return StorePath{getString(json)};
}
void adl_serializer<StorePath>::to_json(json & json, StorePath storePath)
void adl_serializer<StorePath>::to_json(json & json, const StorePath & storePath)
{
json = storePath.to_string();
}

View file

@ -165,7 +165,7 @@ Realisation adl_serializer<Realisation>::from_json(const json & json0)
};
}
void adl_serializer<Realisation>::to_json(json & json, Realisation r)
void adl_serializer<Realisation>::to_json(json & json, const Realisation & r)
{
auto jsonDependentRealisations = nlohmann::json::object();
for (auto & [depId, depOutPath] : r.dependentRealisations)

View file

@ -11,6 +11,6 @@
struct adl_serializer<TYPE> \
{ \
static TYPE from_json(const json & json); \
static void to_json(json & json, TYPE t); \
static void to_json(json & json, const TYPE & t); \
}; \
}