-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 String::remove_char(s)
methods for performance and convenience
#92476
base: master
Are you sure you want to change the base?
Add String::remove_char(s)
methods for performance and convenience
#92476
Conversation
String::remove_char(s)
methods for performance and convenience
bfe4f1e
to
a57b76c
Compare
a57b76c
to
98547f9
Compare
98547f9
to
13d165a
Compare
@@ -1849,7 +1849,7 @@ void EditorHelp::_update_doc() { | |||
_push_code_font(); | |||
|
|||
if (constant.value.begins_with("Color(") && constant.value.ends_with(")")) { | |||
String stripped = constant.value.replace(" ", "").replace("Color(", "").replace(")", ""); | |||
String stripped = constant.value.remove_char(' ').replace("Color(", "").remove_char(')'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could change this to:
String stripped = constant.value.remove_char(' ').replace("Color(", "").remove_char(')'); | |
String stripped = constant.value.remove_chars({ ' ', ')' }).replace("Color(", ""); |
But since the original code keeps the two removes separate I'm unsure if it might cause some issues so left it for now, but if it's considered safe I'll change this
13d165a
to
de7f94f
Compare
de7f94f
to
e79b33c
Compare
e79b33c
to
48f14fc
Compare
48f14fc
to
98ad2ff
Compare
98ad2ff
to
8978147
Compare
8978147
to
92fc76a
Compare
Added an alternative approach based on the changes in: |
43828aa
to
d1e2a8e
Compare
d1e2a8e
to
96e0fde
Compare
96e0fde
to
de97b60
Compare
Reworked with the same logic as the |
Companion to:
String::replace_char(s)
methods for performance and convenience #92475With essentially the same logic and considerations, see there for more reasoning. Will also perform benchmarks on this PR and see about exposing these if desired.
Named it
remove
as the existingerase
method is very different so wanting to avoid confusion between the two.