Skip to content

Commit 045b072

Browse files
committed
Remove Store::queryDerivationOutputNames()
This function was used in only one place, where it could easily be replaced by readDerivation() since it's not performance-critical. (This function appears to have been modelled after queryDerivationOutputs(), which exists only to make the garbage collector faster.)
1 parent 4a4c063 commit 045b072

File tree

11 files changed

+14
-41
lines changed

11 files changed

+14
-41
lines changed

src/libexpr/primops.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
688688
for (auto & j : refs) {
689689
drv.inputSrcs.insert(j.clone());
690690
if (j.isDerivation())
691-
drv.inputDrvs[j.clone()] = state.store->queryDerivationOutputNames(j);
691+
drv.inputDrvs[j.clone()] = readDerivation(*state.store, state.store->toRealPath(j)).outputNames();
692692
}
693693
}
694694

src/libstore/build.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,9 +2723,6 @@ struct RestrictedStore : public LocalFSStore
27232723
StorePathSet queryDerivationOutputs(const StorePath & path) override
27242724
{ throw Error("queryDerivationOutputs"); }
27252725

2726-
StringSet queryDerivationOutputNames(const StorePath & path) override
2727-
{ throw Error("queryDerivationOutputNames"); }
2728-
27292726
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
27302727
{ throw Error("queryPathFromHashPart"); }
27312728

src/libstore/daemon.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
329329
case wopQueryDerivationOutputNames: {
330330
auto path = store->parseStorePath(readString(from));
331331
logger->startWork();
332-
StringSet names;
333-
names = store->queryDerivationOutputNames(path);
332+
auto names = readDerivation(*store, store->toRealPath(path)).outputNames();
334333
logger->stopWork();
335334
to << names;
336335
break;

src/libstore/derivations.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,15 @@ StorePathSet BasicDerivation::outputPaths() const
410410
}
411411

412412

413+
StringSet BasicDerivation::outputNames() const
414+
{
415+
StringSet names;
416+
for (auto & i : outputs)
417+
names.insert(i.first);
418+
return names;
419+
}
420+
421+
413422
Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv)
414423
{
415424
drv.outputs.clear();

src/libstore/derivations.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct BasicDerivation
5858
/* Return the output paths of a derivation. */
5959
StorePathSet outputPaths() const;
6060

61+
/* Return the output names of a derivation. */
62+
StringSet outputNames() const;
6163
};
6264

6365
struct Derivation : BasicDerivation

src/libstore/local-store.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -785,23 +785,6 @@ StorePathSet LocalStore::queryDerivationOutputs(const StorePath & path)
785785
}
786786

787787

788-
StringSet LocalStore::queryDerivationOutputNames(const StorePath & path)
789-
{
790-
return retrySQLite<StringSet>([&]() {
791-
auto state(_state.lock());
792-
793-
auto useQueryDerivationOutputs(state->stmtQueryDerivationOutputs.use()
794-
(queryValidPathId(*state, path)));
795-
796-
StringSet outputNames;
797-
while (useQueryDerivationOutputs.next())
798-
outputNames.insert(useQueryDerivationOutputs.getStr(0));
799-
800-
return outputNames;
801-
});
802-
}
803-
804-
805788
std::optional<StorePath> LocalStore::queryPathFromHashPart(const std::string & hashPart)
806789
{
807790
if (hashPart.size() != storePathHashLen) throw Error("invalid hash part");

src/libstore/local-store.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ public:
135135

136136
StorePathSet queryDerivationOutputs(const StorePath & path) override;
137137

138-
StringSet queryDerivationOutputNames(const StorePath & path) override;
139-
140138
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
141139

142140
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;

src/libstore/remote-store.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,6 @@ StorePathSet RemoteStore::queryDerivationOutputs(const StorePath & path)
418418
}
419419

420420

421-
PathSet RemoteStore::queryDerivationOutputNames(const StorePath & path)
422-
{
423-
auto conn(getConnection());
424-
conn->to << wopQueryDerivationOutputNames << printStorePath(path);
425-
conn.processStderr();
426-
return readStrings<PathSet>(conn->from);
427-
}
428-
429-
430421
std::optional<StorePath> RemoteStore::queryPathFromHashPart(const std::string & hashPart)
431422
{
432423
auto conn(getConnection());

src/libstore/remote-store.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public:
5151

5252
StorePathSet queryDerivationOutputs(const StorePath & path) override;
5353

54-
StringSet queryDerivationOutputNames(const StorePath & path) override;
55-
5654
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
5755

5856
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;

src/libstore/store-api.hh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,6 @@ public:
430430
virtual StorePathSet queryDerivationOutputs(const StorePath & path)
431431
{ unsupported("queryDerivationOutputs"); }
432432

433-
/* Query the output names of the derivation denoted by `path'. */
434-
virtual StringSet queryDerivationOutputNames(const StorePath & path)
435-
{ unsupported("queryDerivationOutputNames"); }
436-
437433
/* Query the full store path given the hash part of a valid store
438434
path, or empty if the path doesn't exist. */
439435
virtual std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) = 0;

0 commit comments

Comments
 (0)