aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-04 18:45:16 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-01-04 18:45:16 +0100
commited93aec3c317e5dc3748b28e451c8eb6df377060 (patch)
treedb9e25912cdf6eb7998c18a1c79b6401d30cad02 /src
parent263a8d293c67488065296737cdadee3d0e122bf5 (diff)
Remove non-method mkPath()
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc7
-rw-r--r--src/libexpr/primops.cc4
-rw-r--r--src/libexpr/value.hh5
3 files changed, 7 insertions, 9 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 591aa6583..cd7d19747 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -786,9 +786,9 @@ void Value::mkString(std::string_view s, const PathSet & context)
}
-void mkPath(Value & v, const char * s)
+void Value::mkPath(std::string_view s)
{
- v.mkPath(dupString(s));
+ mkPath(dupStringWithLen(s.data(), s.size()));
}
@@ -1711,8 +1711,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
else if (firstType == nPath) {
if (!context.empty())
throwEvalError(pos, "a string that refers to a store path cannot be appended to a path");
- auto path = canonPath(s.str());
- mkPath(v, path.c_str());
+ v.mkPath(canonPath(s.str()));
} else
v.mkString(s.str(), context);
}
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 57be5ac23..650200ae4 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1441,7 +1441,7 @@ static void prim_dirOf(EvalState & state, const Pos & pos, Value * * args, Value
{
PathSet context;
Path dir = dirOf(state.coerceToString(pos, *args[0], context, false, false));
- if (args[0]->type() == nPath) mkPath(v, dir.c_str()); else v.mkString(dir, context);
+ if (args[0]->type() == nPath) v.mkPath(dir); else v.mkString(dir, context);
}
static RegisterPrimOp primop_dirOf({
@@ -1522,7 +1522,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
string path = state.forceStringNoCtx(*args[1], pos);
- mkPath(v, state.checkSourcePath(state.findFile(searchPath, path, pos)).c_str());
+ v.mkPath(state.checkSourcePath(state.findFile(searchPath, path, pos)));
}
static RegisterPrimOp primop_findFile(RegisterPrimOp::Info {
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 3f9b65197..ba647a10d 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -248,6 +248,8 @@ public:
path = s;
}
+ void mkPath(std::string_view s);
+
inline void mkNull()
{
clearValue();
@@ -399,9 +401,6 @@ static inline void mkString(Value & v, const Symbol & s)
}
-void mkPath(Value & v, const char * s);
-
-
#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;