[3.x] Optimize hotspots with Object::derives_from
#107881
Merged
+27
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Un-exposes ancestry (so it becomes internal), and instead exposes
Object::_is_class
via a rename toObject::derives_from
.Applies in some use cases.
Object::derives_from()
should be in a lot of cases 1.5x faster in release builds than usingcast_to()
(when a NULL check is not necessary), and will be faster in DEV builds (without optimization). It will also be faster thanObject::is_class(String)
by a huge margin (although we are only worried about hotspots here).Notes
Object::cast_to
andObject::derives_from
.AncestralClass
enum / bitfield, but they will also work with all other classes via the backupGDSOFTCLASS
system.Object::is_class()
uses.Object::is_class()
is still useful for backward compatibility, calling from script (where we don't have an enum of all Object types) and for non-bottleneck areas such as the Editor where we can avoid creating include dependencies.