diff options
author | Juan Linietsky <reduzio@gmail.com> | 2023-04-07 23:32:37 +0200 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2023-04-08 19:25:50 +0200 |
commit | 8950943356b43d08e10df5b13ff03a68ad181324 (patch) | |
tree | 2f301b4aa9d284ed620ac07c658453771f0728a6 /core/object/object.cpp | |
parent | 61630d4e1e279278d29576b979b710b9025f473e (diff) | |
download | redot-engine-8950943356b43d08e10df5b13ff03a68ad181324.tar.gz |
Optimize Object::get_class_name
* Run the static function once per class instead of one per instance.
* Saves some memory in Object derived classes.
Diffstat (limited to 'core/object/object.cpp')
-rw-r--r-- | core/object/object.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp index c324eab9bb..39cae7c5bd 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -195,14 +195,15 @@ bool Object::_predelete() { _predelete_ok = 1; notification(NOTIFICATION_PREDELETE, true); if (_predelete_ok) { - _class_ptr = nullptr; //must restore so destructors can access class ptr correctly + _class_name_ptr = nullptr; // Must restore, so constructors/destructors have proper class name access at each stage. } return _predelete_ok; } void Object::_postinitialize() { - _class_ptr = _get_class_namev(); + _class_name_ptr = _get_class_namev(); // Set the direct pointer, which is much faster to obtain, but can only happen after postinitialize. _initialize_classv(); + _class_name_ptr = nullptr; // May have been called from a constructor. notification(NOTIFICATION_POSTINITIALIZE); } |