Cleanup: Remove singleton()

This commit is contained in:
Eelco Dolstra 2016-05-04 16:04:52 +02:00
parent 0d4a10e910
commit 6c75cf69c3
9 changed files with 23 additions and 35 deletions

View file

@ -87,7 +87,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
Value & w = *state.allocValue();
state.mkAttrs(w, 3 + drv.outputs.size());
Value * v2 = state.allocAttr(w, state.sDrvPath);
mkString(*v2, path, singleton<PathSet>("=" + path));
mkString(*v2, path, {"=" + path});
v2 = state.allocAttr(w, state.sName);
mkString(*v2, drv.env["name"]);
Value * outputsVal =
@ -97,8 +97,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
for (const auto & o : drv.outputs) {
v2 = state.allocAttr(w, state.symbols.create(o.first));
mkString(*v2, o.second.path,
singleton<PathSet>("!" + o.first + "!" + path));
mkString(*v2, o.second.path, {"!" + o.first + "!" + path});
outputsVal->listElems()[outputs_index] = state.allocValue();
mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
}
@ -665,10 +664,10 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
drvHashes[drvPath] = hashDerivationModulo(*state.store, drv);
state.mkAttrs(v, 1 + drv.outputs.size());
mkString(*state.allocAttr(v, state.sDrvPath), drvPath, singleton<PathSet>("=" + drvPath));
mkString(*state.allocAttr(v, state.sDrvPath), drvPath, {"=" + drvPath});
for (auto & i : drv.outputs) {
mkString(*state.allocAttr(v, state.symbols.create(i.first)),
i.second.path, singleton<PathSet>("!" + i.first + "!" + drvPath));
i.second.path, {"!" + i.first + "!" + drvPath});
}
v.attrs->sort();
}
@ -905,7 +904,7 @@ static void prim_toFile(EvalState & state, const Pos & pos, Value * * args, Valu
result, since `storePath' itself has references to the paths
used in args[1]. */
mkString(v, storePath, singleton<PathSet>(storePath));
mkString(v, storePath, {storePath});
}
@ -967,7 +966,7 @@ static void prim_filterSource(EvalState & state, const Pos & pos, Value * * args
? computeStorePathForPath(path, true, htSHA256, filter).first
: state.store->addToStore(baseNameOf(path), path, true, htSHA256, filter, state.repair);
mkString(v, dstPath, singleton<PathSet>(dstPath));
mkString(v, dstPath, {dstPath});
}

View file

@ -2145,8 +2145,7 @@ void DerivationGoal::startBuilder()
/* parent */
pid.setSeparatePG(true);
builderOut.writeSide.close();
worker.childStarted(shared_from_this(),
singleton<set<int> >(builderOut.readSide), true, true);
worker.childStarted(shared_from_this(), {builderOut.readSide}, true, true);
/* Check if setting up the build environment failed. */
while (true) {
@ -3698,7 +3697,7 @@ void LocalStore::ensurePath(const Path & path)
Worker worker(*this);
GoalPtr goal = worker.makeSubstitutionGoal(path);
Goals goals = singleton<Goals>(goal);
Goals goals = {goal};
worker.run(goals);
@ -3711,7 +3710,7 @@ void LocalStore::repairPath(const Path & path)
{
Worker worker(*this);
GoalPtr goal = worker.makeSubstitutionGoal(path, true);
Goals goals = singleton<Goals>(goal);
Goals goals = {goal};
worker.run(goals);

View file

@ -949,7 +949,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<PathSet, Path>(dstPath));
PathLocks outputLock({dstPath});
if (repair || !isValidPath(dstPath)) {
@ -1018,7 +1018,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s,
if (repair || !isValidPath(dstPath)) {
PathLocks outputLock(singleton<PathSet, Path>(dstPath));
PathLocks outputLock({dstPath});
if (repair || !isValidPath(dstPath)) {

View file

@ -222,8 +222,7 @@ void switchLink(Path link, Path target)
void lockProfile(PathLocks & lock, const Path & profile)
{
lock.lockPaths(singleton<PathSet>(profile),
(format("waiting for lock on profile %1%") % profile).str());
lock.lockPaths({profile}, (format("waiting for lock on profile %1%") % profile).str());
lock.setDeletion(true);
}

View file

@ -117,15 +117,6 @@ void createSymlink(const Path & target, const Path & link);
void replaceSymlink(const Path & target, const Path & link);
template<class T, class A>
T singleton(const A & a)
{
T t;
t.insert(a);
return t;
}
/* Wrappers arount read()/write() that read/write exactly the
requested number of bytes. */
void readFull(int fd, unsigned char * buf, size_t count);

View file

@ -195,7 +195,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
case wopHasSubstitutes: {
Path path = readStorePath(from);
startWork();
PathSet res = store->querySubstitutablePaths(singleton<PathSet>(path));
PathSet res = store->querySubstitutablePaths({path});
stopWork();
to << (res.find(path) != res.end());
break;
@ -472,7 +472,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
Path path = absPath(readString(from));
startWork();
SubstitutablePathInfos infos;
store->querySubstitutablePathInfos(singleton<PathSet>(path), infos);
store->querySubstitutablePathInfos({path}, infos);
stopWork();
SubstitutablePathInfos::iterator i = infos.find(path);
if (i == infos.end())

View file

@ -224,7 +224,7 @@ static bool isPrebuilt(EvalState & state, DrvInfo & elem)
{
Path path = elem.queryOutPath();
if (state.store->isValidPath(path)) return true;
PathSet ps = state.store->querySubstitutablePaths(singleton<PathSet>(path));
PathSet ps = state.store->querySubstitutablePaths({path});
return ps.find(path) != ps.end();
}
@ -710,13 +710,13 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
drv.name = globals.forceName;
if (drv.queryDrvPath() != "") {
PathSet paths = singleton<PathSet>(drv.queryDrvPath());
PathSet paths = {drv.queryDrvPath()};
printMissing(globals.state->store, paths);
if (globals.dryRun) return;
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal);
}
else {
printMissing(globals.state->store, singleton<PathSet>(drv.queryOutPath()));
printMissing(globals.state->store, {drv.queryOutPath()});
if (globals.dryRun) return;
globals.state->store->ensurePath(drv.queryOutPath());
}

View file

@ -112,7 +112,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
Value args, topLevel;
state.mkAttrs(args, 3);
mkString(*state.allocAttr(args, state.symbols.create("manifest")),
manifestFile, singleton<PathSet>(manifestFile));
manifestFile, {manifestFile});
args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest));
args.attrs->sort();
mkApp(topLevel, envBuilder, args);
@ -128,7 +128,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
/* Realise the resulting store expression. */
debug("building user environment");
state.store->buildPaths(singleton<PathSet>(topLevelDrv), state.repair ? bmRepair : bmNormal);
state.store->buildPaths({topLevelDrv}, state.repair ? bmRepair : bmNormal);
/* Switch the current user environment to the output path. */
PathLocks lock;

View file

@ -64,7 +64,7 @@ static PathSet realisePath(Path path, bool build = true)
DrvPathWithOutputs p = parseDrvPathWithOutputs(path);
if (isDerivation(p.first)) {
if (build) store->buildPaths(singleton<PathSet>(path));
if (build) store->buildPaths({path});
Derivation drv = store->derivationFromPath(p.first);
rootNr++;
@ -101,7 +101,7 @@ static PathSet realisePath(Path path, bool build = true)
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
path = store->addPermRoot(path, rootName, indirectRoot);
}
return singleton<PathSet>(path);
return {path};
}
}
@ -222,7 +222,7 @@ static PathSet maybeUseOutputs(const Path & storePath, bool useOutput, bool forc
outputs.insert(i.second.path);
return outputs;
}
else return singleton<PathSet>(storePath);
else return {storePath};
}
@ -537,7 +537,7 @@ static void opDumpDB(Strings opFlags, Strings opArgs)
throw UsageError("no arguments expected");
PathSet validPaths = store->queryAllValidPaths();
for (auto & i : validPaths)
cout << store->makeValidityRegistration(singleton<PathSet>(i), true, true);
cout << store->makeValidityRegistration({i}, true, true);
}