forked from lix-project/lix
libstore: have makeLocalDerivationGoal return unique_ptrs
these can be unique rather than shared because shared_ptr has a
converting constructor. preparatory refactor for something else
and not necessary on its own, and the extra allocations we must
do for shared_ptr control blocks isn't usually relevant anyway.
Change-Id: I5391715545240c6ec8e83a031206edafdfc6462f
This commit is contained in:
parent
289e7a6b5a
commit
3f7519526f
|
@ -182,7 +182,7 @@ struct LocalDerivationGoal : public DerivationGoal
|
|||
* Create a LocalDerivationGoal without an on-disk .drv file,
|
||||
* possibly a platform-specific subclass
|
||||
*/
|
||||
static std::shared_ptr<LocalDerivationGoal> makeLocalDerivationGoal(
|
||||
static std::unique_ptr<LocalDerivationGoal> makeLocalDerivationGoal(
|
||||
const StorePath & drvPath,
|
||||
const OutputsSpec & wantedOutputs,
|
||||
Worker & worker,
|
||||
|
@ -194,7 +194,7 @@ struct LocalDerivationGoal : public DerivationGoal
|
|||
* Create a LocalDerivationGoal for an on-disk .drv file,
|
||||
* possibly a platform-specific subclass
|
||||
*/
|
||||
static std::shared_ptr<LocalDerivationGoal> makeLocalDerivationGoal(
|
||||
static std::unique_ptr<LocalDerivationGoal> makeLocalDerivationGoal(
|
||||
const StorePath & drvPath,
|
||||
const BasicDerivation & drv,
|
||||
const OutputsSpec & wantedOutputs,
|
||||
|
|
|
@ -55,7 +55,7 @@ Worker::~Worker()
|
|||
std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<void>> Worker::makeDerivationGoalCommon(
|
||||
const StorePath & drvPath,
|
||||
const OutputsSpec & wantedOutputs,
|
||||
std::function<std::shared_ptr<DerivationGoal>()> mkDrvGoal)
|
||||
std::function<std::unique_ptr<DerivationGoal>()> mkDrvGoal)
|
||||
{
|
||||
auto & goal_weak = derivationGoals[drvPath];
|
||||
std::shared_ptr<DerivationGoal> goal = goal_weak.goal.lock();
|
||||
|
@ -78,9 +78,9 @@ std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<void>> Worker::makeDeriva
|
|||
return makeDerivationGoalCommon(
|
||||
drvPath,
|
||||
wantedOutputs,
|
||||
[&]() -> std::shared_ptr<DerivationGoal> {
|
||||
[&]() -> std::unique_ptr<DerivationGoal> {
|
||||
return !dynamic_cast<LocalStore *>(&store)
|
||||
? std::make_shared<DerivationGoal>(
|
||||
? std::make_unique<DerivationGoal>(
|
||||
drvPath, wantedOutputs, *this, running, buildMode
|
||||
)
|
||||
: LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
|
@ -101,9 +101,9 @@ std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<void>> Worker::makeBasicD
|
|||
return makeDerivationGoalCommon(
|
||||
drvPath,
|
||||
wantedOutputs,
|
||||
[&]() -> std::shared_ptr<DerivationGoal> {
|
||||
[&]() -> std::unique_ptr<DerivationGoal> {
|
||||
return !dynamic_cast<LocalStore *>(&store)
|
||||
? std::make_shared<DerivationGoal>(
|
||||
? std::make_unique<DerivationGoal>(
|
||||
drvPath, drv, wantedOutputs, *this, running, buildMode
|
||||
)
|
||||
: LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
|
|
|
@ -245,7 +245,7 @@ public:
|
|||
private:
|
||||
std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<void>> makeDerivationGoalCommon(
|
||||
const StorePath & drvPath, const OutputsSpec & wantedOutputs,
|
||||
std::function<std::shared_ptr<DerivationGoal>()> mkDrvGoal);
|
||||
std::function<std::unique_ptr<DerivationGoal>()> mkDrvGoal);
|
||||
std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<void>> makeDerivationGoal(
|
||||
const StorePath & drvPath,
|
||||
const OutputsSpec & wantedOutputs, BuildMode buildMode = bmNormal) override;
|
||||
|
|
|
@ -25,7 +25,7 @@ std::shared_ptr<LocalStore> LocalStore::makeLocalStore(const Params & params)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
std::unique_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
const StorePath & drvPath,
|
||||
const OutputsSpec & wantedOutputs,
|
||||
Worker & worker,
|
||||
|
@ -34,17 +34,17 @@ std::shared_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoa
|
|||
)
|
||||
{
|
||||
#if __linux__
|
||||
return std::make_shared<LinuxLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
return std::make_unique<LinuxLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
#elif __APPLE__
|
||||
return std::make_shared<DarwinLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
return std::make_unique<DarwinLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
#elif __FreeBSD__
|
||||
return std::make_shared<FreeBSDLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
return std::make_unique<FreeBSDLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
#else
|
||||
return std::make_shared<FallbackLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
return std::make_unique<FallbackLocalDerivationGoal>(drvPath, wantedOutputs, worker, isDependency, buildMode);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
std::unique_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoal(
|
||||
const StorePath & drvPath,
|
||||
const BasicDerivation & drv,
|
||||
const OutputsSpec & wantedOutputs,
|
||||
|
@ -54,19 +54,19 @@ std::shared_ptr<LocalDerivationGoal> LocalDerivationGoal::makeLocalDerivationGoa
|
|||
)
|
||||
{
|
||||
#if __linux__
|
||||
return std::make_shared<LinuxLocalDerivationGoal>(
|
||||
return std::make_unique<LinuxLocalDerivationGoal>(
|
||||
drvPath, drv, wantedOutputs, worker, isDependency, buildMode
|
||||
);
|
||||
#elif __APPLE__
|
||||
return std::make_shared<DarwinLocalDerivationGoal>(
|
||||
return std::make_unique<DarwinLocalDerivationGoal>(
|
||||
drvPath, drv, wantedOutputs, worker, isDependency, buildMode
|
||||
);
|
||||
#elif __FreeBSD__
|
||||
return std::make_shared<FreeBSDLocalDerivationGoal>(
|
||||
return std::make_unique<FreeBSDLocalDerivationGoal>(
|
||||
drvPath, drv, wantedOutputs, worker, isDependency, buildMode
|
||||
);
|
||||
#else
|
||||
return std::make_shared<FallbackLocalDerivationGoal>(
|
||||
return std::make_unique<FallbackLocalDerivationGoal>(
|
||||
drvPath, drv, wantedOutputs, worker, isDependency, buildMode
|
||||
);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue