From a6e9d9cb2f1738a4e713806e9a80438bf716c272 Mon Sep 17 00:00:00 2001 From: Philipp Otterbein Date: Sat, 24 Dec 2022 12:09:06 +0100 Subject: [PATCH 1/2] remove function makeImmutableStringWithLen --- src/libexpr/eval.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index aee0636b0..da17cca80 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) { From 8af839f48c795370df704c8dd40544c88950c1ed Mon Sep 17 00:00:00 2001 From: Philipp Otterbein Date: Sat, 24 Dec 2022 12:19:53 +0100 Subject: [PATCH 2/2] remove undefined function --- src/libexpr/eval.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index cf307d820..983491a31 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 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);