libexpr: Convert Value::mkStringMove to a constructor
The pseudo-constructor `Value::mkStringMove` would previously be called on a default-constructed (under-initialized) `Value` to create a properly initialized `Value` that represents a string, reusing an existing GC allocated Str. This change turns that method into a proper constructor Change-Id: I8d7a97e2afce231a04ecf56fdd6d22d06a6a6964
This commit is contained in:
@@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ void Value::mkString(std::string_view s, const NixStringContext & context)
|
||||
copyContextToValue(*untag<String *>(), context);
|
||||
}
|
||||
|
||||
void Value::mkStringMove(Str * s, const NixStringContext & context)
|
||||
Value::Value(string_t, Str * s, const NixStringContext & context)
|
||||
{
|
||||
auto block = gcAllocType<String>();
|
||||
*block = {.content = s, .context = nullptr};
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user