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
No known key found for this signature in database
GPG key ID: DEFC5A5B1306947D
67 changed files with 297 additions and 137 deletions

View file

@ -254,7 +254,7 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const
if (p_allow_paths) {
// Dir separators are allowed, but disallow ".." to avoid going up the filesystem
invalid_chars.push_back("..");
safe_dir_name = safe_dir_name.replace("\\", "/").replace("//", "/").strip_edges();
safe_dir_name = safe_dir_name.replace_char('\\', '/').replace("//", "/").strip_edges();
} else {
invalid_chars.push_back("/");
invalid_chars.push_back("\\");