libexpr: remove EvalState& from EvalCache constructor

it's not used for anything any more. it was only passed on to the AttrDb
constructor, which itself only stashed it away to an unused member field

Change-Id: I334fde751a3754e6580f573c21ae3d04be00345a
This commit is contained in:
eldritch horrors 2024-12-03 20:38:41 +01:00
parent 9ff702554d
commit 473c1bdcab
4 changed files with 8 additions and 17 deletions

View file

@ -8,7 +8,7 @@ std::vector<ref<eval_cache::AttrCursor>>
InstallableValue::getCursors() InstallableValue::getCursors()
{ {
auto evalCache = auto evalCache =
std::make_shared<nix::eval_cache::EvalCache>(std::nullopt, *state, std::make_shared<nix::eval_cache::EvalCache>(std::nullopt,
[&]() { return toValue().first; }); [&]() { return toValue().first; });
return {evalCache->getRoot()}; return {evalCache->getRoot()};
} }

View file

@ -419,7 +419,7 @@ ref<eval_cache::EvalCache> openEvalCache(
if (fingerprint) { if (fingerprint) {
return state.getCacheFor(fingerprint.value(), rootLoader); return state.getCacheFor(fingerprint.value(), rootLoader);
} else { } else {
return make_ref<nix::eval_cache::EvalCache>(std::nullopt, state, rootLoader); return make_ref<nix::eval_cache::EvalCache>(std::nullopt, rootLoader);
} }
} }

View file

@ -21,8 +21,6 @@ struct AttrDb
{ {
std::atomic_bool failed{false}; std::atomic_bool failed{false};
const Store & cfg;
struct State struct State
{ {
SQLite db; SQLite db;
@ -35,11 +33,8 @@ struct AttrDb
std::unique_ptr<Sync<State>> _state; std::unique_ptr<Sync<State>> _state;
AttrDb( AttrDb(const Hash & fingerprint)
const Store & cfg, : _state(std::make_unique<Sync<State>>())
const Hash & fingerprint)
: cfg(cfg)
, _state(std::make_unique<Sync<State>>())
{ {
auto state(_state->lock()); auto state(_state->lock());
@ -317,12 +312,10 @@ struct AttrDb
} }
}; };
static std::shared_ptr<AttrDb> makeAttrDb( static std::shared_ptr<AttrDb> makeAttrDb(const Hash & fingerprint)
const Store & cfg,
const Hash & fingerprint)
{ {
try { try {
return std::make_shared<AttrDb>(cfg, fingerprint); return std::make_shared<AttrDb>(fingerprint);
} catch (SQLiteError &) { } catch (SQLiteError &) {
ignoreExceptionExceptInterrupt(); ignoreExceptionExceptInterrupt();
return nullptr; return nullptr;
@ -334,16 +327,15 @@ ref<EvalCache> CachingEvalState::getCacheFor(Hash hash, RootLoader rootLoader)
if (auto it = caches.find(hash); it != caches.end()) { if (auto it = caches.find(hash); it != caches.end()) {
return it->second; return it->second;
} }
auto cache = make_ref<EvalCache>(hash, *this, rootLoader); auto cache = make_ref<EvalCache>(hash, rootLoader);
caches.emplace(hash, cache); caches.emplace(hash, cache);
return cache; return cache;
} }
EvalCache::EvalCache( EvalCache::EvalCache(
std::optional<std::reference_wrapper<const Hash>> useCache, std::optional<std::reference_wrapper<const Hash>> useCache,
EvalState & state,
RootLoader rootLoader) RootLoader rootLoader)
: db(useCache ? makeAttrDb(*state.store, *useCache) : nullptr) : db(useCache ? makeAttrDb(*useCache) : nullptr)
, rootLoader(rootLoader) , rootLoader(rootLoader)
{ {
} }

View file

@ -49,7 +49,6 @@ public:
EvalCache( EvalCache(
std::optional<std::reference_wrapper<const Hash>> useCache, std::optional<std::reference_wrapper<const Hash>> useCache,
EvalState & state,
RootLoader rootLoader); RootLoader rootLoader);
ref<AttrCursor> getRoot(); ref<AttrCursor> getRoot();