aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/nixexpr.hh2
-rw-r--r--src/libexpr/primops.cc10
-rw-r--r--src/libexpr/value.hh13
3 files changed, 11 insertions, 14 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index aa5a3f332..0a60057e5 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -112,7 +112,7 @@ struct ExprString : Expr
{
Symbol s;
Value v;
- ExprString(const Symbol & s) : s(s) { mkString(v, s); };
+ ExprString(const Symbol & s) : s(s) { v.mkString(s); };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env);
};
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 650200ae4..879dfa0a3 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -412,7 +412,7 @@ static void prim_typeOf(EvalState & state, const Pos & pos, Value * * args, Valu
case nFloat: t = "float"; break;
case nThunk: abort();
}
- mkString(v, state.symbols.create(t));
+ v.mkString(state.symbols.create(t));
}
static RegisterPrimOp primop_typeOf({
@@ -2129,7 +2129,7 @@ static void prim_attrNames(EvalState & state, const Pos & pos, Value * * args, V
size_t n = 0;
for (auto & i : *args[0]->attrs)
- mkString(*(v.listElems()[n++] = state.allocValue()), i.name);
+ (v.listElems()[n++] = state.allocValue())->mkString(i.name);
std::sort(v.listElems(), v.listElems() + n,
[](Value * v1, Value * v2) { return strcmp(v1->string.s, v2->string.s) < 0; });
@@ -2477,7 +2477,7 @@ static void prim_mapAttrs(EvalState & state, const Pos & pos, Value * * args, Va
for (auto & i : *args[1]->attrs) {
Value * vName = state.allocValue();
Value * vFun2 = state.allocValue();
- mkString(*vName, i.name);
+ vName->mkString(i.name);
vFun2->mkApp(args[0], vName);
state.allocAttr(v, i.name)->mkApp(vFun2, i.value);
}
@@ -2540,8 +2540,8 @@ static void prim_zipAttrsWith(EvalState & state, const Pos & pos, Value * * args
}
for (auto & attr : *v.attrs) {
- Value * name = state.allocValue();
- mkString(*name, attr.name);
+ auto name = state.allocValue();
+ name->mkString(attr.name);
auto call1 = state.allocValue();
call1->mkApp(args[0], name);
auto call2 = state.allocValue();
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index ba647a10d..7d007ebdc 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -241,6 +241,11 @@ public:
void mkString(std::string_view s, const PathSet & context);
+ inline void mkString(const Symbol & s)
+ {
+ mkString(((const std::string &) s).c_str());
+ }
+
inline void mkPath(const char * s)
{
clearValue();
@@ -393,14 +398,6 @@ public:
};
-
-// TODO: Remove these static functions, replace call sites with v.mk* instead
-static inline void mkString(Value & v, const Symbol & s)
-{
- v.mkString(((const string &) s).c_str());
-}
-
-
#if HAVE_BOEHMGC
typedef std::vector<Value *, traceable_allocator<Value *> > ValueVector;
typedef std::map<Symbol, Value *, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Value *> > > ValueMap;