mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
remove function makeImmutableStringWithLen
This commit is contained in:
parent
26c7602c39
commit
a6e9d9cb2f
1 changed files with 6 additions and 9 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue