1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

Clean up some uses of String::substr

Cases where the end position is either equvalent to the default or past
the end of the string.
This commit is contained in:
A Thousand Ships
2025-02-26 11:41:11 +01:00
parent f2cc3f1275
commit 5113022dfe
54 changed files with 123 additions and 123 deletions

View File

@@ -1563,7 +1563,7 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, Str
String extra_path;
int sep_pos = r->get_path().find("::");
if (sep_pos >= 0) {
extra_path = base_path.substr(sep_pos, base_path.length());
extra_path = base_path.substr(sep_pos);
base_path = base_path.substr(0, sep_pos);
}
@@ -1629,7 +1629,7 @@ void FileSystemDock::_update_project_settings_after_move(const HashMap<String, S
// If the autoload resource paths has a leading "*", it indicates that it is a Singleton,
// so we have to handle both cases when updating.
String autoload = GLOBAL_GET(E.name);
String autoload_singleton = autoload.substr(1, autoload.length());
String autoload_singleton = autoload.substr(1);
if (p_renames.has(autoload)) {
ProjectSettings::get_singleton()->set_setting(E.name, p_renames[autoload]);
} else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) {
@@ -3695,7 +3695,7 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
if (fpath.size() > String("res://").size()) {
fpath = fpath.left(fpath.size() - 2); // Remove last '/'.
const int slash_idx = fpath.rfind_char('/');
fpath = fpath.substr(slash_idx + 1, fpath.size() - slash_idx - 1);
fpath = fpath.substr(slash_idx + 1);
}
tree_item = tree->get_item_with_text(fpath);