Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-introduce mkStringNoCopy #11551

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ EvalState::EvalState(
vNull.mkNull();
vTrue.mkBool(true);
vFalse.mkBool(false);
vStringRegular.mkString("regular");
vStringDirectory.mkString("directory");
vStringSymlink.mkString("symlink");
vStringUnknown.mkString("unknown");
vStringRegular.mkStringNoCopy("regular");
vStringDirectory.mkStringNoCopy("directory");
vStringSymlink.mkStringNoCopy("symlink");
vStringUnknown.mkStringNoCopy("unknown");

/* Construct the Nix expression search path. */
assert(lookupPath.elements.empty());
Expand Down Expand Up @@ -845,7 +845,7 @@ DebugTraceStacker::DebugTraceStacker(EvalState & evalState, DebugTrace t)

void Value::mkString(std::string_view s)
{
mkString(makeImmutableString(s));
mkStringNoCopy(makeImmutableString(s));
}


Expand All @@ -865,12 +865,12 @@ static const char * * encodeContext(const NixStringContext & context)

void Value::mkString(std::string_view s, const NixStringContext & context)
{
mkString(makeImmutableString(s), encodeContext(context));
mkStringNoCopy(makeImmutableString(s), encodeContext(context));
}

void Value::mkStringMove(const char * s, const NixStringContext & context)
{
mkString(s, encodeContext(context));
mkStringNoCopy(s, encodeContext(context));
}

void Value::mkPath(const SourcePath & path)
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4053,7 +4053,7 @@ static void prim_substring(EvalState & state, const PosIdx pos, Value * * args,
if (len == 0) {
state.forceValue(*args[2], pos);
if (args[2]->type() == nString) {
v.mkString("", args[2]->context());
v.mkStringNoCopy("", args[2]->context());
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/primops/fromTOML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value * * args, V
{
if (experimentalFeatureSettings.isEnabled(Xp::ParseTomlTimestamps)) {
auto attrs = state.buildBindings(2);
attrs.alloc("_type").mkString("timestamp");
attrs.alloc("_type").mkStringNoCopy("timestamp");
std::ostringstream s;
s << t;
attrs.alloc("value").mkString(s.str());
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public:
finishValue(tBool, { .boolean = b });
}

inline void mkString(const char * s, const char * * context = 0)
inline void mkStringNoCopy(const char * s, const char * * context = 0)
{
finishValue(tString, { .string = { .c_str = s, .context = context } });
}
Expand All @@ -333,7 +333,7 @@ public:

inline void mkString(const SymbolStr & s)
{
mkString(s.c_str());
mkStringNoCopy(s.c_str());
}

void mkPath(const SourcePath & path);
Expand Down
2 changes: 1 addition & 1 deletion src/nix-env/user-env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool createUserEnv(EvalState & state, PackageInfos & elems,

auto attrs = state.buildBindings(7 + outputs.size());

attrs.alloc(state.sType).mkString("derivation");
attrs.alloc(state.sType).mkStringNoCopy("derivation");
attrs.alloc(state.sName).mkString(i.queryName());
auto system = i.querySystem();
if (!system.empty())
Expand Down
Loading