1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Merge pull request #13345 from xokdvium/use-value-getters

libexpr: Use value getters (NFC)
This commit is contained in:
Robert Hensing 2025-06-11 00:57:39 +02:00 committed by GitHub
commit b3c1b70c19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -126,9 +126,9 @@ std::string showType(const Value & v)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (v.internalType) {
case tString: return v.payload.string.context ? "a string with context" : "a string";
case tString: return v.context() ? "a string with context" : "a string";
case tPrimOp:
return fmt("the built-in function '%s'", std::string(v.payload.primOp->name));
return fmt("the built-in function '%s'", std::string(v.primOp()->name));
case tPrimOpApp:
return fmt("the partially applied built-in function '%s'", v.primOpAppPrimOp()->name);
case tExternal: return v.external()->showType();
@ -2297,8 +2297,8 @@ std::string_view EvalState::forceString(Value & v, const PosIdx pos, std::string
void copyContext(const Value & v, NixStringContext & context, const ExperimentalFeatureSettings & xpSettings)
{
if (v.payload.string.context)
for (const char * * p = v.payload.string.context; *p; ++p)
if (v.context())
for (const char * * p = v.context(); *p; ++p)
context.insert(NixStringContextElem::parse(*p, xpSettings));
}

View file

@ -29,7 +29,7 @@ class SymbolValue : protected Value
public:
operator std::string_view() const noexcept
{
return {payload.string.c_str, size_};
return {c_str(), size_};
}
};
@ -122,7 +122,7 @@ public:
[[gnu::always_inline]]
const char * c_str() const noexcept
{
return s->payload.string.c_str;
return s->c_str();
}
[[gnu::always_inline]]