Skip to content

Commit

Permalink
Make Machine::systemTypes a set not vector
Browse files Browse the repository at this point in the history
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
NixOS/hydra#1164)
  • Loading branch information
Ericson2314 committed Jan 23, 2024
1 parent b6aee9a commit 7390327
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -214,7 +212,7 @@ static int main_build_remote(int argc, char * * argv)

for (auto & m : machines)
error
% concatStringsSep<std::vector<std::string>>(", ", m.systemTypes)
% concatStringsSep<StringSet>(", ", m.systemTypes)
% m.maxJobs
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/machines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static Machine parseBuilderLine(const std::string & line)

return {
tokens[0],
isSet(1) ? tokenizeString<std::vector<std::string>>(tokens[1], ",") : std::vector<std::string>{settings.thisSystem},
isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : std::set<std::string>{settings.thisSystem},
isSet(2) ? tokens[2] : "",
isSet(3) ? parseUnsignedIntField(3) : 1U,
isSet(4) ? parseUnsignedIntField(4) : 1U,
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/machines.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Store;
struct Machine {

const std::string storeUri;
const std::vector<std::string> systemTypes;
const std::set<std::string> systemTypes;
const std::string sshKey;
const unsigned int maxJobs;
const unsigned int speedFactor;
Expand Down

0 comments on commit 7390327

Please sign in to comment.