Add String::replace_char(s) methods for performance and convenience

This commit is contained in:
A Thousand Ships
2024-05-28 12:15:00 +02:00
parent c374ce211c
commit 889410dcda
67 changed files with 297 additions and 137 deletions

View File

@ -123,9 +123,9 @@ void AudioStreamInteractive::set_clip_stream(int p_clip, const Ref<AudioStream>
if (clips[p_clip].name == StringName() && p_stream.is_valid()) {
String n;
if (!clips[p_clip].stream->get_name().is_empty()) {
n = clips[p_clip].stream->get_name().replace(",", " ");
n = clips[p_clip].stream->get_name().replace_char(',', ' ');
} else if (clips[p_clip].stream->get_path().is_resource_file()) {
n = clips[p_clip].stream->get_path().get_file().get_basename().replace(",", " ");
n = clips[p_clip].stream->get_path().get_file().get_basename().replace_char(',', ' ');
n = n.capitalize();
}
@ -395,13 +395,13 @@ String AudioStreamInteractive::_get_streams_hint() const {
if (i > 0) {
stream_name_cache += ",";
}
String n = String(clips[i].name).replace(",", " ");
String n = String(clips[i].name).replace_char(',', ' ');
if (n == "" && clips[i].stream.is_valid()) {
if (!clips[i].stream->get_name().is_empty()) {
n = clips[i].stream->get_name().replace(",", " ");
n = clips[i].stream->get_name().replace_char(',', ' ');
} else if (clips[i].stream->get_path().is_resource_file()) {
n = clips[i].stream->get_path().get_file().replace(",", " ");
n = clips[i].stream->get_path().get_file().replace_char(',', ' ');
}
}