Small cleanups and fixes to StringName. Also increased it's internal table's size.

This commit is contained in:
Relintai 2022-08-22 01:44:53 +02:00
parent ae19991c63
commit 45bec656d5
2 changed files with 12 additions and 4 deletions

View File

@ -118,6 +118,8 @@ void StringName::cleanup() {
print_verbose("StringName: " + itos(lost_strings) + " unclaimed string names at exit.");
}
configured = false;
lock.unlock();
}

View File

@ -41,8 +41,7 @@ struct StaticCString {
class StringName {
enum {
STRING_TABLE_BITS = 12,
STRING_TABLE_BITS = 14,
STRING_TABLE_LEN = 1 << STRING_TABLE_BITS,
STRING_TABLE_MASK = STRING_TABLE_LEN - 1
};
@ -60,16 +59,19 @@ class StringName {
String get_name() const {
return cname ? String(cname) : name;
}
int idx;
uint32_t hash;
_Data *prev;
_Data *next;
_Data() {
#ifdef DEBUG_ENABLED
debug_references = 0;
#endif
cname = nullptr;
next = prev = nullptr;
prev = nullptr;
next = nullptr;
idx = 0;
hash = 0;
}
@ -82,6 +84,10 @@ class StringName {
union _HashUnion {
_Data *ptr;
uint32_t hash;
_HashUnion() {
ptr = nullptr;
}
};
void unref();
@ -119,6 +125,7 @@ public:
if (!_data) {
return false;
}
if (_data->cname != nullptr) {
return _data->cname[0] == '%';
} else {
@ -219,5 +226,4 @@ StringName _scs_create(const char *p_chr, bool p_static = false);
//#define SNAME(m_arg) ([]() -> const StringName & { static StringName sname = _scs_create(m_arg, true); return sname; })()
#endif // STRING_NAME_H