mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
Extract a Value method to get the eval cache
This commit is contained in:
parent
6ec852e7f0
commit
45a28ed36f
3 changed files with 30 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "eval.hh"
|
||||
#include "value-cache.hh"
|
||||
#include "hash.hh"
|
||||
#include "util.hh"
|
||||
#include "store-api.hh"
|
||||
|
|
@ -1190,8 +1191,7 @@ bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector
|
|||
Pos * pos2 = 0;
|
||||
|
||||
forceValue(attrs, pos);
|
||||
if (attrs.type() == nAttrs) {
|
||||
auto eval_cache = attrs.attrs->eval_cache;
|
||||
auto eval_cache = attrs.getEvalCache();
|
||||
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
|
||||
updateCacheStats(cacheResult);
|
||||
switch (cacheResult.returnCode) {
|
||||
|
|
@ -1205,7 +1205,7 @@ bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector
|
|||
case ValueCache::UnCacheable:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Value * vAttrs = &attrs;
|
||||
try {
|
||||
|
|
@ -1802,6 +1802,16 @@ std::vector<std::pair<Path, std::string>> Value::getContext()
|
|||
return res;
|
||||
}
|
||||
|
||||
ValueCache & Value::getEvalCache()
|
||||
{
|
||||
if (internalType == tAttrs) {
|
||||
return attrs->eval_cache;
|
||||
} else {
|
||||
return ValueCache::empty;
|
||||
}
|
||||
}
|
||||
|
||||
ValueCache ValueCache::empty = ValueCache(nullptr);
|
||||
|
||||
string EvalState::forceString(Value & v, PathSet & context, const Pos & pos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
|
||||
ValueCache(tree_cache::Cursor::Ref rawCache) : rawCache(rawCache) {}
|
||||
|
||||
const static ValueCache empty;
|
||||
static ValueCache empty;
|
||||
|
||||
bool isEmpty () { return rawCache == nullptr; }
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ class EvalState;
|
|||
class XMLWriter;
|
||||
class JSONPlaceholder;
|
||||
|
||||
class ValueCache;
|
||||
|
||||
|
||||
typedef int64_t NixInt;
|
||||
typedef double NixFloat;
|
||||
|
|
@ -349,6 +351,8 @@ public:
|
|||
bool isTrivial() const;
|
||||
|
||||
std::vector<std::pair<Path, std::string>> getContext();
|
||||
|
||||
ValueCache & getEvalCache();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue