diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 993876c6d10..47e93d1a211 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2041,8 +2041,7 @@ void DerivationGoal::startBuilder() /* parent */ pid.setSeparatePG(true); builderOut.writeSide.close(); - worker.childStarted(shared_from_this(), pid, - singleton >(builderOut.readSide), true, true); + worker.childStarted(shared_from_this(), pid, std::set{builderOut.readSide}, true, true); /* Check if setting up the build environment failed. */ string msg = readLine(builderOut.readSide); @@ -3168,7 +3167,7 @@ void SubstitutionGoal::tryNext() trace("trying substituter"); SubstitutablePathInfos infos; - PathSet dummy(singleton(storePath)); + PathSet dummy{storePath}; worker.store.querySubstitutablePathInfos(dummy, infos); SubstitutablePathInfos::iterator k = infos.find(storePath); if (k == infos.end()) { @@ -3243,7 +3242,7 @@ void SubstitutionGoal::tryToRun() /* Acquire a lock on the output path. */ outputLock = std::shared_ptr(new PathLocks); - if (!outputLock->lockPaths(singleton(storePath), "", false)) { + if (!outputLock->lockPaths(PathSet{storePath}, "", false)) { worker.waitForAWhile(shared_from_this()); return; } @@ -3842,7 +3841,7 @@ void LocalStore::ensurePath(const Path & path) Worker worker(*this); GoalPtr goal = worker.makeSubstitutionGoal(path); - Goals goals = singleton(goal); + Goals goals{goal}; worker.run(goals); @@ -3855,7 +3854,7 @@ void LocalStore::repairPath(const Path & path) { Worker worker(*this); GoalPtr goal = worker.makeSubstitutionGoal(path, true); - Goals goals = singleton(goal); + Goals goals{goal}; worker.run(goals); diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc index f6540c2117d..d544253add8 100644 --- a/nix/libstore/local-store.cc +++ b/nix/libstore/local-store.cc @@ -1015,7 +1015,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name, /* The first check above is an optimisation to prevent unnecessary lock acquisition. */ - PathLocks outputLock(singleton(dstPath)); + PathLocks outputLock{ PathSet{dstPath} }; if (repair || !isValidPath(dstPath)) { @@ -1084,7 +1084,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s, if (repair || !isValidPath(dstPath)) { - PathLocks outputLock(singleton(dstPath)); + PathLocks outputLock{ PathSet{dstPath} }; if (repair || !isValidPath(dstPath)) { @@ -1380,7 +1380,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source) lock on this path). */ Strings locksHeld = tokenizeString(getEnv("NIX_HELD_LOCKS")); if (find(locksHeld.begin(), locksHeld.end(), dstPath) == locksHeld.end()) - outputLock.lockPaths(singleton(dstPath)); + outputLock.lockPaths(PathSet{dstPath}); if (!isValidPath(dstPath)) { diff --git a/nix/libutil/types.hh b/nix/libutil/types.hh index 160884ee1ad..62889e6fa99 100644 --- a/nix/libutil/types.hh +++ b/nix/libutil/types.hh @@ -76,24 +76,24 @@ public: }; -typedef list Strings; -typedef set StringSet; +using Strings = std::list; +using StringSet = std::set; /* Paths are just strings. */ -typedef string Path; -typedef list Paths; -typedef set PathSet; +using Path = std::string; +using Paths = std::list; +using PathSet = std::set; -typedef enum { +enum Verbosity { lvlError = 0, lvlInfo, lvlTalkative, lvlChatty, lvlDebug, lvlVomit -} Verbosity; +}; } diff --git a/nix/libutil/util.hh b/nix/libutil/util.hh index 03234e3a5d2..176247e699d 100644 --- a/nix/libutil/util.hh +++ b/nix/libutil/util.hh @@ -121,15 +121,6 @@ Paths createDirs(const Path & path); void createSymlink(const Path & target, const Path & link); -template -T singleton(const A & a) -{ - T t; - t.insert(a); - return t; -} - - /* Messages. */ diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index e29237e65dd..b43bcf7fc6e 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -336,7 +336,7 @@ static void performOp(bool trusted, unsigned int clientVersion, case wopHasSubstitutes: { Path path = readStorePath(from); startWork(); - PathSet res = store->querySubstitutablePaths(singleton(path)); + PathSet res = store->querySubstitutablePaths(PathSet{path}); stopWork(); writeInt(res.find(path) != res.end(), to); break; @@ -656,7 +656,7 @@ static void performOp(bool trusted, unsigned int clientVersion, Path path = absPath(readString(from)); startWork(); SubstitutablePathInfos infos; - store->querySubstitutablePathInfos(singleton(path), infos); + store->querySubstitutablePathInfos(PathSet{path}, infos); stopWork(); SubstitutablePathInfos::iterator i = infos.find(path); if (i == infos.end())