mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +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);
|
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
|
||||||
updateCacheStats(cacheResult);
|
updateCacheStats(cacheResult);
|
||||||
switch (cacheResult.returnCode) {
|
|
||||||
case ValueCache::CacheHit:
|
auto delayValue = [&](ValueCache & cursor) {
|
||||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
|
||||||
return LazyValueType::Missing;
|
|
||||||
return LazyValueType::PlainValue;
|
|
||||||
case ValueCache::Forward: {
|
|
||||||
auto recordAsVar = new ExprCastedVar(&attrs);
|
auto recordAsVar = new ExprCastedVar(&attrs);
|
||||||
auto accessExpr = new ExprSelect(pos, recordAsVar, selector);
|
auto accessExpr = new ExprSelect(pos, recordAsVar, selector);
|
||||||
auto thunk = (Thunk*)allocBytes(sizeof(Thunk));
|
auto thunk = (Thunk*)allocBytes(sizeof(Thunk));
|
||||||
@ -1212,10 +1208,21 @@ EvalState::LazyValueType EvalState::lazyGetAttrField(Value & attrs, const std::v
|
|||||||
|
|
||||||
dest.mkCachedThunk(
|
dest.mkCachedThunk(
|
||||||
thunk,
|
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:
|
default:
|
||||||
if(getAttrField(attrs, selector, pos, dest))
|
if(getAttrField(attrs, selector, pos, dest))
|
||||||
return LazyValueType::PlainValue;
|
return LazyValueType::PlainValue;
|
||||||
|
@ -359,7 +359,8 @@ public:
|
|||||||
|
|
||||||
enum struct LazyValueType {
|
enum struct LazyValueType {
|
||||||
PlainValue,
|
PlainValue,
|
||||||
DelayedAttrSet,
|
DelayedUncacheable,
|
||||||
|
DelayedAttr,
|
||||||
Missing,
|
Missing,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,8 +98,9 @@ struct CmdSearch : InstallableCommand, MixJSON
|
|||||||
attrPath2.push_back(attrName);
|
attrPath2.push_back(attrName);
|
||||||
auto attrValue = state->allocValue();
|
auto attrValue = state->allocValue();
|
||||||
auto value_ = allocRootValue(attrValue);
|
auto value_ = allocRootValue(attrValue);
|
||||||
state->lazyGetAttrField(current, {attrName}, noPos,
|
auto childField = state->lazyGetAttrField(current, {attrName}, noPos,
|
||||||
*attrValue);
|
*attrValue);
|
||||||
|
if (childField != EvalState::LazyValueType::DelayedUncacheable)
|
||||||
visit(*attrValue, attrPath2, false);
|
visit(*attrValue, attrPath2, false);
|
||||||
} catch (EvalError &e) {
|
} catch (EvalError &e) {
|
||||||
if (!(attrPath.size() > 0 &&
|
if (!(attrPath.size() > 0 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user