aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-01-02 11:41:52 +0100
committerGitHub <noreply@github.com>2023-01-02 11:41:52 +0100
commitb3285c77223445067a15f4aa81103e2fc28ac582 (patch)
treec2251bcf8f7c69a54cfb187c033c63e8f66a92a4 /src
parente8a3e581710d43e8df12bee0b2bd10ae69159b04 (diff)
parent8af839f48c795370df704c8dd40544c88950c1ed (diff)
Merge pull request #7351 from NaN-git/fix-mkString
cleanup eval.hh/eval.cc
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc15
-rw-r--r--src/libexpr/eval.hh1
2 files changed, 6 insertions, 10 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 084ccbee2..ebf14b659 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -67,22 +67,19 @@ static char * dupString(const char * s)
// When there's no need to write to the string, we can optimize away empty
// string allocations.
-// This function handles makeImmutableStringWithLen(null, 0) by returning the
-// empty string.
-static const char * makeImmutableStringWithLen(const char * s, size_t size)
+// This function handles makeImmutableString(std::string_view()) by returning
+// the empty string.
+static const char * makeImmutableString(std::string_view s)
{
+ const size_t size = s.size();
if (size == 0)
return "";
auto t = allocString(size + 1);
- memcpy(t, s, size);
- t[size] = 0;
+ memcpy(t, s.data(), size);
+ t[size] = '\0';
return t;
}
-static inline const char * makeImmutableString(std::string_view s) {
- return makeImmutableStringWithLen(s.data(), s.size());
-}
-
RootValue allocRootValue(Value * v)
{
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 21666339b..346b2cb31 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -60,7 +60,6 @@ void copyContext(const Value & v, PathSet & context);
typedef std::map<Path, StorePath> SrcToStore;
-std::ostream & printValue(const EvalState & state, std::ostream & str, const Value & v);
std::string printValue(const EvalState & state, const Value & v);
std::ostream & operator << (std::ostream & os, const ValueType t);