@@ -582,7 +582,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
582582 }
583583 if (isFunctor (v)) {
584584 try {
585- Value & functor = *v.attrs ()->find (s.functor )->value ;
585+ Value & functor = *v.attrs ()->get (s.functor )->value ;
586586 Value * vp[] = {&v};
587587 Value partiallyApplied;
588588 // The first parameter is not user-provided, and may be
@@ -1709,8 +1709,8 @@ void EvalState::autoCallFunction(const Bindings & args, Value & fun, Value & res
17091709 forceValue (fun, pos);
17101710
17111711 if (fun.type () == nAttrs) {
1712- auto found = fun.attrs ()->find (s.functor );
1713- if (found != fun. attrs ()-> end () ) {
1712+ auto found = fun.attrs ()->get (s.functor );
1713+ if (found) {
17141714 Value * v = allocValue ();
17151715 callFunction (*found->value , fun, *v, pos);
17161716 forceValue (*v, pos);
@@ -2160,18 +2160,18 @@ bool EvalState::forceBool(Value & v, const PosIdx pos, std::string_view errorCtx
21602160 return v.boolean ();
21612161}
21622162
2163- Bindings::const_iterator EvalState::getAttr (Symbol attrSym, const Bindings * attrSet, std::string_view errorCtx)
2163+ const Attr * EvalState::getAttr (Symbol attrSym, const Bindings * attrSet, std::string_view errorCtx)
21642164{
2165- auto value = attrSet->find (attrSym);
2166- if (value == attrSet-> end () ) {
2165+ auto value = attrSet->get (attrSym);
2166+ if (! value) {
21672167 error<TypeError>(" attribute '%s' missing" , symbols[attrSym]).withTrace (noPos, errorCtx).debugThrow ();
21682168 }
21692169 return value;
21702170}
21712171
21722172bool EvalState::isFunctor (const Value & fun) const
21732173{
2174- return fun.type () == nAttrs && fun.attrs ()->find (s.functor ) != fun. attrs ()-> end ( );
2174+ return fun.type () == nAttrs && fun.attrs ()->get (s.functor );
21752175}
21762176
21772177void EvalState::forceFunction (Value & v, const PosIdx pos, std::string_view errorCtx)
@@ -2252,8 +2252,8 @@ bool EvalState::isDerivation(Value & v)
22522252std::optional<std::string>
22532253EvalState::tryAttrsToString (const PosIdx pos, Value & v, NixStringContext & context, bool coerceMore, bool copyToStore)
22542254{
2255- auto i = v.attrs ()->find (s.toString );
2256- if (i != v. attrs ()-> end () ) {
2255+ auto i = v.attrs ()->get (s.toString );
2256+ if (i) {
22572257 Value v1;
22582258 callFunction (*i->value , v, v1, pos);
22592259 return coerceToString (
@@ -2298,8 +2298,8 @@ BackedStringView EvalState::coerceToString(
22982298 auto maybeString = tryAttrsToString (pos, v, context, coerceMore, copyToStore);
22992299 if (maybeString)
23002300 return std::move (*maybeString);
2301- auto i = v.attrs ()->find (s.outPath );
2302- if (i == v. attrs ()-> end () ) {
2301+ auto i = v.attrs ()->get (s.outPath );
2302+ if (!i ) {
23032303 error<TypeError>(
23042304 " cannot coerce %1% to a string: %2%" , showType (v), ValuePrinter (*this , v, errorPrintOptions))
23052305 .withTrace (pos, errorCtx)
@@ -2403,8 +2403,8 @@ SourcePath EvalState::coerceToPath(const PosIdx pos, Value & v, NixStringContext
24032403 /* Similarly, handle __toString where the result may be a path
24042404 value. */
24052405 if (v.type () == nAttrs) {
2406- auto i = v.attrs ()->find (s.toString );
2407- if (i != v. attrs ()-> end () ) {
2406+ auto i = v.attrs ()->get (s.toString );
2407+ if (i) {
24082408 Value v1;
24092409 callFunction (*i->value , v, v1, pos);
24102410 return coerceToPath (pos, v1, context, errorCtx);
0 commit comments