diff options
Diffstat (limited to 'core/string/string_name.h')
-rw-r--r-- | core/string/string_name.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/string/string_name.h b/core/string/string_name.h index 6f08d32981..ff4c41af94 100644 --- a/core/string/string_name.h +++ b/core/string/string_name.h @@ -35,6 +35,8 @@ #include "core/string/ustring.h" #include "core/templates/safe_refcount.h" +#define UNIQUE_NODE_PREFIX "%" + class Main; struct StaticCString { @@ -70,7 +72,7 @@ class StringName { _Data *_data = nullptr; union _HashUnion { - _Data *ptr; + _Data *ptr = nullptr; uint32_t hash; }; @@ -100,6 +102,17 @@ public: bool operator==(const String &p_name) const; bool operator==(const char *p_name) const; bool operator!=(const String &p_name) const; + + _FORCE_INLINE_ bool is_node_unique_name() const { + if (!_data) { + return false; + } + if (_data->cname != nullptr) { + return (char32_t)_data->cname[0] == (char32_t)UNIQUE_NODE_PREFIX[0]; + } else { + return (char32_t)_data->name[0] == (char32_t)UNIQUE_NODE_PREFIX[0]; + } + } _FORCE_INLINE_ bool operator<(const StringName &p_name) const { return _data < p_name._data; } |