Remove unnecessary StringName idx cache in _Data to reduce its size by 4 bytes.

Encapsulate `StringName` details in its cpp file.
This commit is contained in:
Lukas Tenbrink
2025-04-25 19:22:29 +02:00
parent 28089c40c1
commit 3b31636985
2 changed files with 52 additions and 76 deletions

View File

@@ -39,11 +39,7 @@
class Main;
class StringName {
enum {
STRING_TABLE_BITS = 16,
STRING_TABLE_LEN = 1 << STRING_TABLE_BITS,
STRING_TABLE_MASK = STRING_TABLE_LEN - 1
};
struct Table;
struct _Data {
SafeRefCount refcount;
@@ -52,28 +48,19 @@ class StringName {
#ifdef DEBUG_ENABLED
uint32_t debug_references = 0;
#endif
const String &get_name() const { return name; }
bool operator==(const String &p_name) const;
bool operator!=(const String &p_name) const;
bool operator==(const char *p_name) const;
bool operator!=(const char *p_name) const;
int idx = 0;
uint32_t hash = 0;
_Data *prev = nullptr;
_Data *next = nullptr;
_Data() {}
};
static inline _Data *_table[STRING_TABLE_LEN];
_Data *_data = nullptr;
void unref();
friend void register_core_types();
friend void unregister_core_types();
friend class Main;
static inline Mutex mutex;
static void setup();
static void cleanup();
static uint32_t get_empty_hash();