diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-07-20 23:28:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 23:28:35 +0200 |
commit | b5e5eed7ae199a2bc5cf7fe7b08ed33b847bff25 (patch) | |
tree | bc4c8b822d5af2fa199e875e93fa396ad77f864d /core/string/string_name.h | |
parent | c82daaed483e7ab7df7e44c2d01a906154801905 (diff) | |
parent | cee905f04f453dc7823690bc5c7595a1ee7ef2cd (diff) | |
download | redot-engine-b5e5eed7ae199a2bc5cf7fe7b08ed33b847bff25.tar.gz |
Merge pull request #50663 from reduz/debug-stringnames
Diffstat (limited to 'core/string/string_name.h')
-rw-r--r-- | core/string/string_name.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/string/string_name.h b/core/string/string_name.h index f5e7ff509d..ce7988744b 100644 --- a/core/string/string_name.h +++ b/core/string/string_name.h @@ -52,10 +52,11 @@ class StringName { struct _Data { SafeRefCount refcount; SafeNumeric<uint32_t> static_count; - SafeRefCount static_refcount; const char *cname = nullptr; String name; - +#ifdef DEBUG_ENABLED + uint32_t debug_references = 0; +#endif String get_name() const { return cname ? String(cname) : name; } int idx = 0; uint32_t hash = 0; @@ -81,6 +82,15 @@ class StringName { static void setup(); static void cleanup(); static bool configured; +#ifdef DEBUG_ENABLED + struct DebugSortReferences { + bool operator()(const _Data *p_left, const _Data *p_right) const { + return p_left->debug_references > p_right->debug_references; + } + }; + + static bool debug_stringname; +#endif StringName(_Data *p_data) { _data = p_data; } @@ -158,6 +168,10 @@ public: unref(); } } + +#ifdef DEBUG_ENABLED + static void set_debug_stringnames(bool p_enable) { debug_stringname = p_enable; } +#endif }; bool operator==(const String &p_name, const StringName &p_string_name); |