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

String: Remove erase method, bindings can't mutate String #54869

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Nov 11, 2021

An alternative to removing this function would be to have it return a copy, like insert() does.

But there were only a handful of places using it and this was often not the most optimal approach anyway, so we might as well remove.

Part of #43311.

@akien-mga akien-mga marked this pull request as ready for review November 11, 2021 10:24
@akien-mga akien-mga requested review from a team as code owners November 11, 2021 10:24
@akien-mga
Copy link
Member Author

Proofread and tested briefly, seems to work as expected.

@akien-mga akien-mga merged commit 1aa3c84 into godotengine:master Nov 11, 2021
@akien-mga akien-mga deleted the string-remove-erase branch November 11, 2021 12:00
@DaGamingWolf
Copy link

DaGamingWolf commented Mar 1, 2023

for the record, i protest this. With erase() gone, now if we want to remove an invalid character from the smack dab middle of a text, it requires manually copying each character to an array just so that we can use the Array's erase() method, the text clean, then copy each character back from the array into the text. There's no way this is more optimal approach.

@vnen
Copy link
Member

vnen commented Mar 4, 2023

@DaGamingWolf you can see the implementation of String::erase() here and copy it to your script. It will be pretty much the same in terms of performance.

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