@@ -2366,12 +2366,15 @@ BackedStringView EvalState::coerceToString(
23662366 }
23672367
23682368 if (v.type () == nPath) {
2369- return !canonicalizePath && !copyToStore
2370- ? // FIXME: hack to preserve path literals that end in a
2371- // slash, as in /foo/${x}.
2372- v.pathStr ()
2373- : copyToStore ? store->printStorePath (copyPathToStore (context, v.path ()))
2374- : std::string (v.path ().path .abs ());
2369+ if (!canonicalizePath && !copyToStore) {
2370+ // FIXME: hack to preserve path literals that end in a
2371+ // slash, as in /foo/${x}.
2372+ return v.pathStrView ();
2373+ } else if (copyToStore) {
2374+ return store->printStorePath (copyPathToStore (context, v.path ()));
2375+ } else {
2376+ return std::string{v.path ().path .abs ()};
2377+ }
23752378 }
23762379
23772380 if (v.type () == nAttrs) {
@@ -2624,7 +2627,7 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
26242627 return ;
26252628
26262629 case nString:
2627- if (strcmp ( v1.c_str (), v2.c_str ()) != 0 ) {
2630+ if (v1.string_view () != v2.string_view () ) {
26282631 error<AssertionError>(
26292632 " string '%s' is not equal to string '%s'" ,
26302633 ValuePrinter (*this , v1, errorPrintOptions),
@@ -2641,7 +2644,7 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
26412644 ValuePrinter (*this , v2, errorPrintOptions))
26422645 .debugThrow ();
26432646 }
2644- if (strcmp ( v1.pathStr (), v2.pathStr ()) != 0 ) {
2647+ if (v1.pathStrView () != v2.pathStrView () ) {
26452648 error<AssertionError>(
26462649 " path '%s' is not equal to path '%s'" ,
26472650 ValuePrinter (*this , v1, errorPrintOptions),
@@ -2807,12 +2810,12 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
28072810 return v1.boolean () == v2.boolean ();
28082811
28092812 case nString:
2810- return strcmp ( v1.c_str (), v2.c_str ()) == 0 ;
2813+ return v1.string_view () == v2.string_view () ;
28112814
28122815 case nPath:
28132816 return
28142817 // FIXME: compare accessors by their fingerprint.
2815- v1.pathAccessor () == v2.pathAccessor () && strcmp ( v1.pathStr (), v2.pathStr ()) == 0 ;
2818+ v1.pathAccessor () == v2.pathAccessor () && v1.pathStrView () == v2.pathStrView () ;
28162819
28172820 case nNull:
28182821 return true ;
0 commit comments