mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Use less c_str() in the evaluator, and other cleanups
It is better to avoid null termination for performance and memory safety, wherever possible. These are good cleanups extracted from the Pascal String work that we can land by themselves first, shrinking the diff in that PR. Co-Authored-By: Aspen Smith <root@gws.fyi> Co-Authored-By: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
parent
2d83bc6b83
commit
bd42092873
16 changed files with 64 additions and 38 deletions
|
|
@ -82,7 +82,7 @@ static void printValueAsXML(
|
|||
case nString:
|
||||
/* !!! show the context? */
|
||||
copyContext(v, context);
|
||||
doc.writeEmptyElement("string", singletonAttrs("value", v.c_str()));
|
||||
doc.writeEmptyElement("string", singletonAttrs("value", v.string_view()));
|
||||
break;
|
||||
|
||||
case nPath:
|
||||
|
|
@ -102,14 +102,14 @@ static void printValueAsXML(
|
|||
if (strict)
|
||||
state.forceValue(*a->value, a->pos);
|
||||
if (a->value->type() == nString)
|
||||
xmlAttrs["drvPath"] = drvPath = a->value->c_str();
|
||||
xmlAttrs["drvPath"] = drvPath = a->value->string_view();
|
||||
}
|
||||
|
||||
if (auto a = v.attrs()->get(state.s.outPath)) {
|
||||
if (strict)
|
||||
state.forceValue(*a->value, a->pos);
|
||||
if (a->value->type() == nString)
|
||||
xmlAttrs["outPath"] = a->value->c_str();
|
||||
xmlAttrs["outPath"] = a->value->string_view();
|
||||
}
|
||||
|
||||
XMLOpenElement _(doc, "derivation", xmlAttrs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue