You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user