1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00

AttrCursor::Parent: shared_ptr -> ref

(cherry picked from commit 5a35745949)
This commit is contained in:
Eelco Dolstra 2025-03-31 15:14:10 +02:00
parent 8b448c841e
commit 64fb6ab435
2 changed files with 5 additions and 5 deletions

View file

@ -423,7 +423,7 @@ void AttrCursor::fetchCachedValue()
if (!cachedValue)
cachedValue = root->db->getAttr(getKey());
if (cachedValue && std::get_if<failed_t>(&cachedValue->second) && parent)
throw CachedEvalError(ref(parent->first), parent->second);
throw CachedEvalError(parent->first, parent->second);
}
std::vector<Symbol> AttrCursor::getAttrPath() const
@ -508,7 +508,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
if (auto attrs = std::get_if<std::vector<Symbol>>(&cachedValue->second)) {
for (auto & attr : *attrs)
if (attr == name)
return std::make_shared<AttrCursor>(root, std::make_pair(shared_from_this(), attr));
return std::make_shared<AttrCursor>(root, std::make_pair(ref(shared_from_this()), attr));
return nullptr;
} else if (std::get_if<placeholder_t>(&cachedValue->second)) {
auto attr = root->db->getAttr({cachedValue->first, name});
@ -519,7 +519,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
throw CachedEvalError(ref(shared_from_this()), name);
else
return std::make_shared<AttrCursor>(root,
std::make_pair(shared_from_this(), name), nullptr, std::move(attr));
std::make_pair(ref(shared_from_this()), name), nullptr, std::move(attr));
}
// Incomplete attrset, so need to fall thru and
// evaluate to see whether 'name' exists
@ -554,7 +554,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
}
return make_ref<AttrCursor>(
root, std::make_pair(shared_from_this(), name), attr->value, std::move(cachedValue2));
root, std::make_pair(ref(shared_from_this()), name), attr->value, std::move(cachedValue2));
}
std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(std::string_view name)

View file

@ -90,7 +90,7 @@ class AttrCursor : public std::enable_shared_from_this<AttrCursor>
friend struct CachedEvalError;
ref<EvalCache> root;
typedef std::optional<std::pair<std::shared_ptr<AttrCursor>, Symbol>> Parent;
using Parent = std::optional<std::pair<ref<AttrCursor>, Symbol>>;
Parent parent;
RootValue _value;
std::optional<std::pair<AttrId, AttrValue>> cachedValue;