Skip to content

[3.x] Optimize hotspots with Object::is_reference() #107877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

lawnjelly
Copy link
Member

3.x equivalent of is_ref_counted() in 4.x.

This is both easier to read, and faster in release (in case where pointer NULL check is not required) by 1.5x, and faster in debug because pointer check won't be optimized out.

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I don't think we want to expose similar functions for other ancestral classes, but for Reference one I think it's fine because

  • Reference violates Object's life cycle, so it already kind of is fundamentally different.
  • is_ref_counted exists in 4.x too

@lawnjelly lawnjelly merged commit cd5503a into godotengine:3.x Jun 23, 2025
14 checks passed
@lawnjelly
Copy link
Member Author

Thanks!

@lawnjelly lawnjelly deleted the is_reference branch June 23, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants