-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add reset
to CowData
, to bring it on-par with other collections.
#101393
base: master
Are you sure you want to change the base?
Conversation
…Add comments to `clear` to warn about the discrepancy between this API and others.
Not sure about this one, it's identical to I don't see the usefulness of this, which should be the guiding principle behind new features |
For me this is about API consistency, which is key to reducing complexity in large codebases. imo, it was incorrect to call the function |
But this doesn't add consistency, it adds something that's present in three out of 15 or more classes to three more, that's reducing consistency If it did something unique I'd say it would make sense, but now it just creates an alias for |
😄 you got a point there! The reason I chose |
I'd say consistency in this case means "a class has the function if it actually needs it", not "slap the function on anything". Also this method should either be bound on The exact same concept applies to |
Yeah, that's probably true! Valid reason to stall merging this PR until |
Agreed, I think adding a
|
In most APIs,
clear()
destroys all elements but keeps the capacity intact. This is the case for STL collections, as well asLocalVector
.LocalVector
additionally declaresreset
to give up the backing buffer.CowData
and related classes have no way to shrink without giving up the buffer (godotengine/godot-proposals#2954). As such,clear()
behavior cannot be changed to be on-par withLocalVector
. But we can certainly bring the APIs closer together by addingreset()
and letting users use that instead ofclear()
if an explicit dealloc of the buffer is wanted (which is probably most cases).