From 8950943356b43d08e10df5b13ff03a68ad181324 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 7 Apr 2023 23:32:37 +0200 Subject: Optimize Object::get_class_name * Run the static function once per class instead of one per instance. * Saves some memory in Object derived classes. --- core/object/object.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/object/object.cpp') 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); } -- cgit v1.2.3