mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
Make nix search lazier
Only 4 evals left \o/
This commit is contained in:
parent
71650c83c6
commit
ea792bcdc8
@ -1198,12 +1198,8 @@ EvalState::LazyValueType EvalState::lazyGetAttrField(Value & attrs, const std::v
|
||||
}
|
||||
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
|
||||
updateCacheStats(cacheResult);
|
||||
switch (cacheResult.returnCode) {
|
||||
case ValueCache::CacheHit:
|
||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||
return LazyValueType::Missing;
|
||||
return LazyValueType::PlainValue;
|
||||
case ValueCache::Forward: {
|
||||
|
||||
auto delayValue = [&](ValueCache & cursor) {
|
||||
auto recordAsVar = new ExprCastedVar(&attrs);
|
||||
auto accessExpr = new ExprSelect(pos, recordAsVar, selector);
|
||||
auto thunk = (Thunk*)allocBytes(sizeof(Thunk));
|
||||
@ -1212,10 +1208,21 @@ EvalState::LazyValueType EvalState::lazyGetAttrField(Value & attrs, const std::v
|
||||
|
||||
dest.mkCachedThunk(
|
||||
thunk,
|
||||
new ValueCache(resultingCursor)
|
||||
new ValueCache(cursor)
|
||||
);
|
||||
return LazyValueType::DelayedAttrSet;
|
||||
}
|
||||
};
|
||||
|
||||
switch (cacheResult.returnCode) {
|
||||
case ValueCache::CacheHit:
|
||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||
return LazyValueType::Missing;
|
||||
return LazyValueType::PlainValue;
|
||||
case ValueCache::UnCacheable:
|
||||
delayValue(resultingCursor);
|
||||
return LazyValueType::DelayedUncacheable;
|
||||
case ValueCache::Forward:
|
||||
delayValue(resultingCursor);
|
||||
return LazyValueType::DelayedAttr;
|
||||
default:
|
||||
if(getAttrField(attrs, selector, pos, dest))
|
||||
return LazyValueType::PlainValue;
|
||||
|
@ -359,7 +359,8 @@ public:
|
||||
|
||||
enum struct LazyValueType {
|
||||
PlainValue,
|
||||
DelayedAttrSet,
|
||||
DelayedUncacheable,
|
||||
DelayedAttr,
|
||||
Missing,
|
||||
};
|
||||
|
||||
|
@ -98,8 +98,9 @@ struct CmdSearch : InstallableCommand, MixJSON
|
||||
attrPath2.push_back(attrName);
|
||||
auto attrValue = state->allocValue();
|
||||
auto value_ = allocRootValue(attrValue);
|
||||
state->lazyGetAttrField(current, {attrName}, noPos,
|
||||
auto childField = state->lazyGetAttrField(current, {attrName}, noPos,
|
||||
*attrValue);
|
||||
if (childField != EvalState::LazyValueType::DelayedUncacheable)
|
||||
visit(*attrValue, attrPath2, false);
|
||||
} catch (EvalError &e) {
|
||||
if (!(attrPath.size() > 0 &&
|
||||
|
Loading…
Reference in New Issue
Block a user