aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-01-10 10:29:06 -0500
committerShea Levy <shea@shealevy.com>2017-01-10 10:29:06 -0500
commitd771c28613908aa8ac6aa72ceeca9048fbbcb776 (patch)
treed424a0006071b671ba615a729f9957977ba3ec91
parentbff3ad767ec21b37f291a2c4ae0eac7d91470ce5 (diff)
build-remote: Use std::set for feature sets
-rw-r--r--src/build-remote/build-remote.cc32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index 82e5bb225..cf1062636 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -3,7 +3,7 @@
#include <algorithm>
#include <fstream>
#include <sstream>
-#include <vector>
+#include <set>
#include <memory>
#include <tuple>
#include <iomanip>
@@ -24,8 +24,8 @@ static void handle_alarm(int sig) {
}
class machine {
- const std::vector<string> supportedFeatures;
- const std::vector<string> mandatoryFeatures;
+ const std::set<string> supportedFeatures;
+ const std::set<string> mandatoryFeatures;
public:
const string hostName;
@@ -35,22 +35,18 @@ public:
const unsigned long long speedFactor;
bool enabled;
- bool allSupported(const std::vector<string> & features) const {
+ bool allSupported(const std::set<string> & features) const {
return std::all_of(features.begin(), features.end(),
[&](const string & feature) {
- return std::find(supportedFeatures.begin(),
- supportedFeatures.end(),
- feature) != supportedFeatures.end() ||
- std::find(mandatoryFeatures.begin(),
- mandatoryFeatures.end(),
- feature) != mandatoryFeatures.end();
+ return supportedFeatures.count(feature) ||
+ mandatoryFeatures.count(feature);
});
}
- bool mandatoryMet(const std::vector<string> & features) const {
+ bool mandatoryMet(const std::set<string> & features) const {
return std::all_of(mandatoryFeatures.begin(), mandatoryFeatures.end(),
[&](const string & feature) {
- return std::find(features.begin(), features.end(), feature) != features.end();
+ return features.count(feature);
});
}
@@ -96,11 +92,11 @@ static std::vector<machine> read_conf() {
stoull(tokens[3]),
sz >= 5 ? stoull(tokens[4]) : 1LL,
sz >= 6 ?
- tokenizeString<std::vector<string>>(tokens[5], ",") :
- std::vector<string>{},
+ tokenizeString<std::set<string>>(tokens[5], ",") :
+ std::set<string>{},
sz >= 7 ?
- tokenizeString<std::vector<string>>(tokens[6], ",") :
- std::vector<string>{});
+ tokenizeString<std::set<string>>(tokens[6], ",") :
+ std::set<string>{});
}
}
confFile.close();
@@ -160,8 +156,8 @@ int main (int argc, char * * argv)
auto neededSystem = tokens[1];
drvPath = tokens[2];
auto requiredFeatures = sz == 3 ?
- std::vector<string>{} :
- tokenizeString<std::vector<string>>(tokens[3], ",");
+ std::set<string>{} :
+ tokenizeString<std::set<string>>(tokens[3], ",");
auto canBuildLocally = amWilling && (neededSystem == localSystem);
/* Error ignored here, will be caught later */