aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorPhilipp Otterbein <potterbein@blockstream.com>2022-12-24 12:09:06 +0100
committerPhilipp Otterbein <potterbein@blockstream.com>2022-12-24 12:09:06 +0100
commita6e9d9cb2f1738a4e713806e9a80438bf716c272 (patch)
treeba62ff8b5d2771c463547856acf251572e0fa47c /src/libexpr
parent26c7602c390f8c511f326785b570918b2f468892 (diff)
remove function makeImmutableStringWithLen
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc15
1 files 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)
{