Optimize Object::get_class_name
* Run the static function once per class instead of one per instance. * Saves some memory in Object derived classes.
This commit is contained in:
@ -201,6 +201,14 @@ StringName::StringName(const StringName &p_name) {
|
||||
}
|
||||
}
|
||||
|
||||
void StringName::assign_static_unique_class_name(StringName *ptr, const char *p_name) {
|
||||
mutex.lock();
|
||||
if (*ptr == StringName()) {
|
||||
*ptr = StringName(p_name, true);
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
StringName::StringName(const char *p_name, bool p_static) {
|
||||
_data = nullptr;
|
||||
|
||||
|
||||
@ -177,6 +177,8 @@ public:
|
||||
StringName(const String &p_name, bool p_static = false);
|
||||
StringName(const StaticCString &p_static_string, bool p_static = false);
|
||||
StringName() {}
|
||||
|
||||
static void assign_static_unique_class_name(StringName *ptr, const char *p_name);
|
||||
_FORCE_INLINE_ ~StringName() {
|
||||
if (likely(configured) && _data) { //only free if configured
|
||||
unref();
|
||||
|
||||
Reference in New Issue
Block a user