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

Abstract CowData's reallocations into _realloc to consolidate duplicate logic. #100474

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

Ivorforce
Copy link
Member

One can see that both code blocks were the same. The logic may further be used in the future to optimize other CowData functions that grow or shrink the array for various reasons.

The current refcount returned by copy_on_write is guaranteed to be 1 in cases where realloc is called (i.e. an array exists, and we've forked off already). Therefore, it is safe to just init refcount with 1.

Copy link
Member

@hpvb hpvb left a comment

Choose a reason for hiding this comment

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

LGTM, less code is better code.

@Ivorforce Ivorforce force-pushed the cowdata-abstract-realloc branch from 1528815 to 8483d79 Compare December 19, 2024 16:35
@Repiteo Repiteo merged commit 1b8a2d9 into godotengine:master Dec 20, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 20, 2024

Thanks!

@Ivorforce Ivorforce deleted the cowdata-abstract-realloc branch December 20, 2024 08:42
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.

4 participants