From 739032762addcb3d88490040b388ff63b155bb16 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 23 Jan 2024 12:30:26 -0500 Subject: [PATCH] Make `Machine::systemTypes` a set not vector This is more conceptually correct (the order does not matter), and also matches what Hydra already does. (Nix and Hydra matching is needed for dedup https://github.com/NixOS/hydra/issues/1164) --- src/build-remote/build-remote.cc | 6 ++---- src/libstore/machines.cc | 2 +- src/libstore/machines.hh | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index d69d3a0c2..b6704152a 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -139,9 +139,7 @@ static int main_build_remote(int argc, char * * argv) if (m.enabled && (neededSystem == "builtin" - || std::find(m.systemTypes.begin(), - m.systemTypes.end(), - neededSystem) != m.systemTypes.end()) && + || m.systemTypes.count(neededSystem) > 0) && m.allSupported(requiredFeatures) && m.mandatoryMet(requiredFeatures)) { @@ -214,7 +212,7 @@ static int main_build_remote(int argc, char * * argv) for (auto & m : machines) error - % concatStringsSep>(", ", m.systemTypes) + % concatStringsSep(", ", m.systemTypes) % m.maxJobs % concatStringsSep(", ", m.supportedFeatures) % concatStringsSep(", ", m.mandatoryFeatures); diff --git a/src/libstore/machines.cc b/src/libstore/machines.cc index 512115893..8a1da84cd 100644 --- a/src/libstore/machines.cc +++ b/src/libstore/machines.cc @@ -145,7 +145,7 @@ static Machine parseBuilderLine(const std::string & line) return { tokens[0], - isSet(1) ? tokenizeString>(tokens[1], ",") : std::vector{settings.thisSystem}, + isSet(1) ? tokenizeString>(tokens[1], ",") : std::set{settings.thisSystem}, isSet(2) ? tokens[2] : "", isSet(3) ? parseUnsignedIntField(3) : 1U, isSet(4) ? parseUnsignedIntField(4) : 1U, diff --git a/src/libstore/machines.hh b/src/libstore/machines.hh index 1adeaf1f0..d25fdf1b3 100644 --- a/src/libstore/machines.hh +++ b/src/libstore/machines.hh @@ -10,7 +10,7 @@ class Store; struct Machine { const std::string storeUri; - const std::vector systemTypes; + const std::set systemTypes; const std::string sshKey; const unsigned int maxJobs; const unsigned int speedFactor;