diff --git a/lix/libexpr/eval-expr.cc b/lix/libexpr/eval-expr.cc index 11566d8c2..414bb297c 100644 --- a/lix/libexpr/eval-expr.cc +++ b/lix/libexpr/eval-expr.cc @@ -541,7 +541,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v) } v = {NewValueAs::path, CanonPath(canonPath(str()))}; } else { - v.mkStringMove(gcStr(), context); + v = {NewValueAs::string, gcStr(), context}; } } diff --git a/lix/libexpr/value.cc b/lix/libexpr/value.cc index 420fd5b22..c720ea1bc 100644 --- a/lix/libexpr/value.cc +++ b/lix/libexpr/value.cc @@ -74,7 +74,7 @@ void Value::mkString(std::string_view s, const NixStringContext & context) copyContextToValue(*untag(), context); } -void Value::mkStringMove(Str * s, const NixStringContext & context) +Value::Value(string_t, Str * s, const NixStringContext & context) { auto block = gcAllocType(); *block = {.content = s, .context = nullptr}; diff --git a/lix/libexpr/value.hh b/lix/libexpr/value.hh index 1b443e9bb..4a35abf41 100644 --- a/lix/libexpr/value.hh +++ b/lix/libexpr/value.hh @@ -447,6 +447,12 @@ public: raw = tag(tString, block); } + /// Constructs a nix language value of type "string", with the value of the + /// C-string pointed to by @ref s, and context from @ref context. + /// + /// The C-string is not copied but the data from context is + Value(string_t, Str * s, const NixStringContext & context); + Value(string_t, const String * str) : raw(tag(tString, str)) {} /// Constructx a nix language value of type "string", with a copy of the @@ -784,8 +790,6 @@ public: void mkString(std::string_view s, const NixStringContext & context); - void mkStringMove(Str * s, const NixStringContext & context); - inline void mkNull() { *this = {NewValueAs::null};