forked from lix-project/lix
remove function makeImmutableStringWithLen
This commit is contained in:
parent
26c7602c39
commit
a6e9d9cb2f
|
@ -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
|
// When there's no need to write to the string, we can optimize away empty
|
||||||
// string allocations.
|
// string allocations.
|
||||||
// This function handles makeImmutableStringWithLen(null, 0) by returning the
|
// This function handles makeImmutableString(std::string_view()) by returning
|
||||||
// empty string.
|
// the empty string.
|
||||||
static const char * makeImmutableStringWithLen(const char * s, size_t size)
|
static const char * makeImmutableString(std::string_view s)
|
||||||
{
|
{
|
||||||
|
const size_t size = s.size();
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return "";
|
return "";
|
||||||
auto t = allocString(size + 1);
|
auto t = allocString(size + 1);
|
||||||
memcpy(t, s, size);
|
memcpy(t, s.data(), size);
|
||||||
t[size] = 0;
|
t[size] = '\0';
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char * makeImmutableString(std::string_view s) {
|
|
||||||
return makeImmutableStringWithLen(s.data(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RootValue allocRootValue(Value * v)
|
RootValue allocRootValue(Value * v)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue