diff options
author | NaN <ptsamd@gmail.com> | 2024-07-14 03:15:25 +0200 |
---|---|---|
committer | nan-git <ptsamd@gmail.com> | 2024-07-14 02:13:58 +0000 |
commit | 505640baec97f7fcbf3c0629ef0a201a29bbe6e4 (patch) | |
tree | f16661c80e96f282ce993a50c70e201a04e86b03 /src/libexpr | |
parent | a8f443d96011c11ad726c2a28a37752bd56c12cc (diff) |
libexpr/eval.cc: remove unnecessary C string conversion
Change-Id: I5b7c21df84ff8ff64cf6a1e261fc3729a06bd4f6
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 2ef3abc52..ced92136b 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -65,19 +65,6 @@ static char * allocString(size_t size) } -static char * dupString(const char * s) -{ - char * t; -#if HAVE_BOEHMGC - t = GC_STRDUP(s); -#else - t = strdup(s); -#endif - if (!t) throw std::bad_alloc(); - return t; -} - - // When there's no need to write to the string, we can optimize away empty // string allocations. // This function handles makeImmutableString(std::string_view()) by returning @@ -889,7 +876,7 @@ static void copyContextToValue(Value & v, const NixStringContext & context) v.string.context = (const char * *) allocBytes((context.size() + 1) * sizeof(char *)); for (auto & i : context) - v.string.context[n++] = dupString(i.to_string().c_str()); + v.string.context[n++] = makeImmutableString(i.to_string()); v.string.context[n] = 0; } } |