Remove bool from Object::notification virtual function; replace with separate functions to avoid branching.
This commit is contained in:
parent
b13c96b097
commit
8a76e31547
3 changed files with 91 additions and 61 deletions
|
|
@ -911,18 +911,14 @@ Variant Object::call_const(const StringName &p_method, const Variant **p_args, i
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Object::notification(int p_notification, bool p_reversed) {
|
||||
if (p_reversed) {
|
||||
if (script_instance) {
|
||||
script_instance->notification(p_notification, p_reversed);
|
||||
}
|
||||
} else {
|
||||
_notificationv(p_notification, p_reversed);
|
||||
}
|
||||
void Object::_notification_forward(int p_notification) {
|
||||
// Notify classes starting with Object and ending with most derived subclass.
|
||||
// e.g. Object -> Node -> Node3D
|
||||
_notification_forwardv(p_notification);
|
||||
|
||||
if (_extension) {
|
||||
if (_extension->notification2) {
|
||||
_extension->notification2(_extension_instance, p_notification, static_cast<GDExtensionBool>(p_reversed));
|
||||
_extension->notification2(_extension_instance, p_notification, static_cast<GDExtensionBool>(false));
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
} else if (_extension->notification) {
|
||||
_extension->notification(_extension_instance, p_notification);
|
||||
|
|
@ -930,13 +926,29 @@ void Object::notification(int p_notification, bool p_reversed) {
|
|||
}
|
||||
}
|
||||
|
||||
if (p_reversed) {
|
||||
_notificationv(p_notification, p_reversed);
|
||||
} else {
|
||||
if (script_instance) {
|
||||
script_instance->notification(p_notification, p_reversed);
|
||||
if (script_instance) {
|
||||
script_instance->notification(p_notification, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::_notification_backward(int p_notification) {
|
||||
if (script_instance) {
|
||||
script_instance->notification(p_notification, true);
|
||||
}
|
||||
|
||||
if (_extension) {
|
||||
if (_extension->notification2) {
|
||||
_extension->notification2(_extension_instance, p_notification, static_cast<GDExtensionBool>(true));
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
} else if (_extension->notification) {
|
||||
_extension->notification(_extension_instance, p_notification);
|
||||
#endif // DISABLE_DEPRECATED
|
||||
}
|
||||
}
|
||||
|
||||
// Notify classes starting with most derived subclass and ending in Object.
|
||||
// e.g. Node3D -> Node -> Object
|
||||
_notification_backwardv(p_notification);
|
||||
}
|
||||
|
||||
String Object::to_string() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue