Skip to content
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

Simplify RefCounted check in free() #87331

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jan 18, 2024

Use the is_ref_counted() method, which does a simple bool check, instead of casting.

@KoBeWi KoBeWi added this to the 4.3 milestone Jan 18, 2024
@KoBeWi KoBeWi requested a review from a team as a code owner January 18, 2024 11:55
@akien-mga
Copy link
Member

Are we confident that this is always in sync for any Object?

@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 18, 2024

It's initialized directly in the RefCounted constructor:

RefCounted::RefCounted() :
Object(true) {

godot/core/object/object.cpp

Lines 1958 to 1963 in 1952f64

Object::Object(bool p_reference) {
_construct_object(p_reference);
}
Object::Object() {
_construct_object(false);

No other class overrides it, so it's safe to rely on.

@akien-mga akien-mga merged commit 266ae93 into godotengine:master Jan 18, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the you_can_ref_count_on_that branch January 18, 2024 15:38
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