From ed93aec3c317e5dc3748b28e451c8eb6df377060 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Jan 2022 18:45:16 +0100 Subject: [PATCH] Remove non-method mkPath() --- src/libexpr/eval.cc | 7 +++---- src/libexpr/primops.cc | 4 ++-- src/libexpr/value.hh | 5 ++--- 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 > ValueVector; typedef std::map, traceable_allocator > > ValueMap;