Remove unused StaticString
This commit is contained in:
parent
4843643514
commit
348e23dd8a
|
@ -14,8 +14,7 @@ struct StringData : UseMemoryDomain<MemoryDomain::SharedString>
|
||||||
int refcount;
|
int refcount;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
StringData() = default;
|
constexpr StringData(int ref, int len) : refcount(ref), length(len) {}
|
||||||
constexpr StringData(int refcount, int length) : refcount(refcount), length(length) {}
|
|
||||||
|
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
char* data() { return reinterpret_cast<char*>(this + 1); }
|
char* data() { return reinterpret_cast<char*>(this + 1); }
|
||||||
|
@ -43,13 +42,12 @@ struct StringData : UseMemoryDomain<MemoryDomain::SharedString>
|
||||||
|
|
||||||
friend void inc_ref_count(StringData* s, void*)
|
friend void inc_ref_count(StringData* s, void*)
|
||||||
{
|
{
|
||||||
if (s->refcount != -1)
|
|
||||||
++s->refcount;
|
++s->refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend void dec_ref_count(StringData* s, void*)
|
friend void dec_ref_count(StringData* s, void*)
|
||||||
{
|
{
|
||||||
if (s->refcount != -1 and --s->refcount == 0)
|
if (--s->refcount == 0)
|
||||||
StringData::destroy(s);
|
StringData::destroy(s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -61,22 +59,6 @@ inline StringDataPtr operator"" _ss(const char* ptr, size_t len)
|
||||||
return StringData::create({ptr, (int)len});
|
return StringData::create({ptr, (int)len});
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t len>
|
|
||||||
struct StaticStringData : StringData
|
|
||||||
{
|
|
||||||
template<size_t... I> constexpr
|
|
||||||
StaticStringData(const char (&literal)[len], IndexSequence<I...>)
|
|
||||||
: StringData{-1, len}, data{literal[I]...} {}
|
|
||||||
|
|
||||||
const char data[len];
|
|
||||||
};
|
|
||||||
|
|
||||||
template<size_t len>
|
|
||||||
constexpr StaticStringData<len> static_storage(const char (&literal)[len])
|
|
||||||
{
|
|
||||||
return { literal, make_index_sequence<len>() };
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedString : public StringView
|
class SharedString : public StringView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -105,8 +105,6 @@ void test_utf8()
|
||||||
kak_assert(utf8::codepoint(str.begin() + 2, str.end()) == 0x00EF);
|
kak_assert(utf8::codepoint(str.begin() + 2, str.end()) == 0x00EF);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto ss_static_str = static_storage("yeehaa");
|
|
||||||
|
|
||||||
void test_string()
|
void test_string()
|
||||||
{
|
{
|
||||||
kak_assert(String("youpi ") + "matin" == "youpi matin");
|
kak_assert(String("youpi ") + "matin" == "youpi matin");
|
||||||
|
@ -139,8 +137,6 @@ void test_string()
|
||||||
kak_assert(subsequence_match("tchou kanaky", "knk"));
|
kak_assert(subsequence_match("tchou kanaky", "knk"));
|
||||||
kak_assert(subsequence_match("tchou kanaky", "tchou kanaky"));
|
kak_assert(subsequence_match("tchou kanaky", "tchou kanaky"));
|
||||||
kak_assert(not subsequence_match("tchou kanaky", "tchou kanaky"));
|
kak_assert(not subsequence_match("tchou kanaky", "tchou kanaky"));
|
||||||
|
|
||||||
kak_assert(ss_static_str.refcount == -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_keys()
|
void test_keys()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user