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:
parent
f2cc3f1275
commit
5113022dfe
54 changed files with 123 additions and 123 deletions
|
|
@ -4662,7 +4662,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||
for (int i = 0; i < subindices.size(); i++) {
|
||||
InsertData id = p_id;
|
||||
id.type = Animation::TYPE_BEZIER;
|
||||
id.value = subindices[i].is_empty() ? p_id.value : p_id.value.get(subindices[i].substr(1, subindices[i].length()));
|
||||
id.value = subindices[i].is_empty() ? p_id.value : p_id.value.get(subindices[i].substr(1));
|
||||
id.path = String(p_id.path) + subindices[i];
|
||||
p_next_tracks = _confirm_insert(id, p_next_tracks, p_reset_wanted, p_reset_anim, false);
|
||||
}
|
||||
|
|
@ -6515,7 +6515,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
text = path;
|
||||
int sep = text.find_char(':');
|
||||
if (sep != -1) {
|
||||
text = text.substr(sep + 1, text.length());
|
||||
text = text.substr(sep + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
|
|||
stack.push_back(category);
|
||||
categories.push_back(category);
|
||||
|
||||
name = name.substr(1, name.length());
|
||||
name = name.substr(1);
|
||||
|
||||
category->set_text(0, name);
|
||||
category->set_metadata(1, cpu_time);
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ void EditorAutoloadSettings::_autoload_edited() {
|
|||
String scr_path = GLOBAL_GET(base);
|
||||
|
||||
if (scr_path.begins_with("*")) {
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
scr_path = scr_path.substr(1);
|
||||
}
|
||||
|
||||
// Singleton autoloads are represented with a leading "*" in their path.
|
||||
|
|
@ -494,7 +494,7 @@ void EditorAutoloadSettings::update_autoload() {
|
|||
info.is_singleton = scr_path.begins_with("*");
|
||||
|
||||
if (info.is_singleton) {
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
scr_path = scr_path.substr(1);
|
||||
}
|
||||
|
||||
info.name = name;
|
||||
|
|
@ -873,7 +873,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
|||
info.is_singleton = scr_path.begins_with("*");
|
||||
|
||||
if (info.is_singleton) {
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
scr_path = scr_path.substr(1);
|
||||
}
|
||||
|
||||
info.name = name;
|
||||
|
|
|
|||
|
|
@ -1846,7 +1846,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
|
|||
if (!f.begins_with("res://")) {
|
||||
return false;
|
||||
}
|
||||
f = f.substr(6, f.length());
|
||||
f = f.substr(6);
|
||||
f = f.replace("\\", "/");
|
||||
|
||||
Vector<String> path = f.split("/");
|
||||
|
|
@ -1972,7 +1972,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
f = f.substr(6, f.length());
|
||||
f = f.substr(6);
|
||||
f = f.replace("\\", "/");
|
||||
if (f.is_empty()) {
|
||||
return filesystem;
|
||||
|
|
|
|||
|
|
@ -2517,7 +2517,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C
|
|||
int brk_end = bbcode.find_char(']', brk_pos + 1);
|
||||
|
||||
if (brk_end == -1) {
|
||||
p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos).replace("\n", "\n\n"));
|
||||
p_rt->add_text(bbcode.substr(brk_pos).replace("\n", "\n\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6819,7 +6819,7 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
|
|||
{
|
||||
MutexLock lock(eta.execute_output_mutex);
|
||||
if (prev_len != eta.output.length()) {
|
||||
String to_add = eta.output.substr(prev_len, eta.output.length());
|
||||
String to_add = eta.output.substr(prev_len);
|
||||
prev_len = eta.output.length();
|
||||
execute_outputs->add_text(to_add);
|
||||
DisplayServer::get_singleton()->process_events(); // Get rid of pending events.
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
}
|
||||
|
||||
for (const String &extension : extensions) {
|
||||
if (filesPaths[0].ends_with(extension.substr(1, extension.size() - 1))) {
|
||||
if (filesPaths[0].ends_with(extension.substr(1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -807,11 +807,11 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint
|
|||
String subtype_string = p_hint_string.substr(0, hint_subtype_separator);
|
||||
int slash_pos = subtype_string.find_char('/');
|
||||
if (slash_pos >= 0) {
|
||||
subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int());
|
||||
subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1).to_int());
|
||||
subtype_string = subtype_string.substr(0, slash_pos);
|
||||
}
|
||||
|
||||
subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1, p_hint_string.size() - hint_subtype_separator - 1);
|
||||
subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1);
|
||||
subtype = Variant::Type(subtype_string.to_int());
|
||||
}
|
||||
}
|
||||
|
|
@ -1090,11 +1090,11 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s
|
|||
String key_subtype_string = key.substr(0, hint_key_subtype_separator);
|
||||
int slash_pos = key_subtype_string.find_char('/');
|
||||
if (slash_pos >= 0) {
|
||||
key_subtype_hint = PropertyHint(key_subtype_string.substr(slash_pos + 1, key_subtype_string.size() - slash_pos - 1).to_int());
|
||||
key_subtype_hint = PropertyHint(key_subtype_string.substr(slash_pos + 1).to_int());
|
||||
key_subtype_string = key_subtype_string.substr(0, slash_pos);
|
||||
}
|
||||
|
||||
key_subtype_hint_string = key.substr(hint_key_subtype_separator + 1, key.size() - hint_key_subtype_separator - 1);
|
||||
key_subtype_hint_string = key.substr(hint_key_subtype_separator + 1);
|
||||
key_subtype = Variant::Type(key_subtype_string.to_int());
|
||||
|
||||
Variant new_key = object->get_new_item_key();
|
||||
|
|
@ -1109,11 +1109,11 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s
|
|||
String value_subtype_string = value.substr(0, hint_value_subtype_separator);
|
||||
int slash_pos = value_subtype_string.find_char('/');
|
||||
if (slash_pos >= 0) {
|
||||
value_subtype_hint = PropertyHint(value_subtype_string.substr(slash_pos + 1, value_subtype_string.size() - slash_pos - 1).to_int());
|
||||
value_subtype_hint = PropertyHint(value_subtype_string.substr(slash_pos + 1).to_int());
|
||||
value_subtype_string = value_subtype_string.substr(0, slash_pos);
|
||||
}
|
||||
|
||||
value_subtype_hint_string = value.substr(hint_value_subtype_separator + 1, value.size() - hint_value_subtype_separator - 1);
|
||||
value_subtype_hint_string = value.substr(hint_value_subtype_separator + 1);
|
||||
value_subtype = Variant::Type(value_subtype_string.to_int());
|
||||
|
||||
Variant new_value = object->get_new_item_value();
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ Vector<Vector<String>> get_extractable_message_list() {
|
|||
list.push_back(msgs);
|
||||
}
|
||||
msg_context = "";
|
||||
l = l.substr(7, l.length()).strip_edges();
|
||||
l = l.substr(7).strip_edges();
|
||||
status = STATUS_READING_CONTEXT;
|
||||
entered_context = true;
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ Vector<Vector<String>> get_extractable_message_list() {
|
|||
if (status != STATUS_READING_ID) {
|
||||
ERR_FAIL_V_MSG(Vector<Vector<String>>(), "Unexpected 'msgid_plural', was expecting 'msgid' before 'msgid_plural' while parsing: " + path + ":" + itos(line));
|
||||
}
|
||||
l = l.substr(12, l.length()).strip_edges();
|
||||
l = l.substr(12).strip_edges();
|
||||
status = STATUS_READING_PLURAL;
|
||||
} else if (l.begins_with("msgid")) {
|
||||
ERR_FAIL_COND_V_MSG(status == STATUS_READING_ID, Vector<Vector<String>>(), "Unexpected 'msgid', was expecting 'msgstr' while parsing: " + path + ":" + itos(line));
|
||||
|
|
@ -257,7 +257,7 @@ Vector<Vector<String>> get_extractable_message_list() {
|
|||
list.push_back(msgs);
|
||||
}
|
||||
|
||||
l = l.substr(5, l.length()).strip_edges();
|
||||
l = l.substr(5).strip_edges();
|
||||
status = STATUS_READING_ID;
|
||||
// If we did not encounter msgctxt, we reset context to empty to reset it.
|
||||
if (!entered_context) {
|
||||
|
|
@ -271,11 +271,11 @@ Vector<Vector<String>> get_extractable_message_list() {
|
|||
if (l.begins_with("msgstr[")) {
|
||||
ERR_FAIL_COND_V_MSG(status != STATUS_READING_PLURAL, Vector<Vector<String>>(),
|
||||
"Unexpected 'msgstr[]', was expecting 'msgid_plural' before 'msgstr[]' while parsing: " + path + ":" + itos(line));
|
||||
l = l.substr(9, l.length()).strip_edges();
|
||||
l = l.substr(9).strip_edges();
|
||||
} else if (l.begins_with("msgstr")) {
|
||||
ERR_FAIL_COND_V_MSG(status != STATUS_READING_ID, Vector<Vector<String>>(),
|
||||
"Unexpected 'msgstr', was expecting 'msgid' before 'msgstr' while parsing: " + path + ":" + itos(line));
|
||||
l = l.substr(6, l.length()).strip_edges();
|
||||
l = l.substr(6).strip_edges();
|
||||
status = STATUS_READING_STRING;
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ Vector<Vector<String>> get_extractable_message_list() {
|
|||
|
||||
ERR_FAIL_COND_V_MSG(!l.begins_with("\"") || status == STATUS_NONE, Vector<Vector<String>>(), "Invalid line '" + l + "' while parsing: " + path + ":" + itos(line));
|
||||
|
||||
l = l.substr(1, l.length());
|
||||
l = l.substr(1);
|
||||
// Find final quote, ignoring escaped ones (\").
|
||||
// The escape_next logic is necessary to properly parse things like \\"
|
||||
// where the backslash is the one being escaped, not the quote.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void EditorFileDialog::_native_dialog_cb(bool p_ok, const Vector<String> &p_file
|
|||
|
||||
if (!valid && filter_slice_count > 0) {
|
||||
String str = (flt.get_slice(",", 0).strip_edges());
|
||||
f += str.substr(1, str.length() - 1);
|
||||
f += str.substr(1);
|
||||
file->set_text(f.get_file());
|
||||
valid = true;
|
||||
}
|
||||
|
|
@ -650,7 +650,7 @@ void EditorFileDialog::_action_pressed() {
|
|||
|
||||
if (!valid && filter_slice_count > 0) {
|
||||
String str = (flt.get_slice(",", 0).strip_edges());
|
||||
f += str.substr(1, str.length() - 1);
|
||||
f += str.substr(1);
|
||||
_request_single_thumbnail(get_current_dir().path_join(f.get_file()));
|
||||
file->set_text(f.get_file());
|
||||
valid = true;
|
||||
|
|
@ -1436,7 +1436,7 @@ void EditorFileDialog::set_current_path(const String &p_path) {
|
|||
set_current_file(p_path);
|
||||
} else {
|
||||
String path_dir = p_path.substr(0, pos);
|
||||
String path_file = p_path.substr(pos + 1, p_path.length());
|
||||
String path_file = p_path.substr(pos + 1);
|
||||
set_current_dir(path_dir);
|
||||
set_current_file(path_file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void Collada::Vertex::fix_unit_scale(const Collada &p_state) {
|
|||
|
||||
static String _uri_to_id(const String &p_uri) {
|
||||
if (p_uri.begins_with("#")) {
|
||||
return p_uri.substr(1, p_uri.size() - 1);
|
||||
return p_uri.substr(1);
|
||||
} else {
|
||||
return p_uri;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
|
|||
face[1] = face[2];
|
||||
}
|
||||
} else if (l.begins_with("s ")) { //smoothing
|
||||
String what = l.substr(2, l.length()).strip_edges();
|
||||
String what = l.substr(2).strip_edges();
|
||||
bool do_smooth;
|
||||
if (what == "off") {
|
||||
do_smooth = false;
|
||||
|
|
@ -476,7 +476,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
|
|||
}
|
||||
|
||||
if (l.begins_with("o ")) {
|
||||
name = l.substr(2, l.length()).strip_edges();
|
||||
name = l.substr(2).strip_edges();
|
||||
}
|
||||
|
||||
if (l.begins_with("usemtl ")) {
|
||||
|
|
@ -484,7 +484,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
|
|||
}
|
||||
|
||||
if (l.begins_with("g ")) {
|
||||
current_group = l.substr(2, l.length()).strip_edges();
|
||||
current_group = l.substr(2).strip_edges();
|
||||
}
|
||||
|
||||
} else if (l.begins_with("mtllib ")) { //parse material
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ static String _fixstr(const String &p_what, const String &p_str) {
|
|||
what = what.substr(0, what.length() - 1);
|
||||
}
|
||||
|
||||
String end = p_what.substr(what.length(), p_what.length() - what.length());
|
||||
String end = p_what.substr(what.length());
|
||||
|
||||
if (what.containsn("$" + p_str)) { // Blender and other stuff.
|
||||
return what.replace("$" + p_str, "") + end;
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ void LocalizationEditor::update_translations() {
|
|||
const String &s2 = selected[j];
|
||||
int qp = s2.rfind_char(':');
|
||||
String path = s2.substr(0, qp);
|
||||
String locale = s2.substr(qp + 1, s2.length());
|
||||
String locale = s2.substr(qp + 1);
|
||||
|
||||
TreeItem *t2 = translation_remap_options->create_item(root2);
|
||||
t2->set_editable(0, false);
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
|
|||
for (int i = 0; i < headers.size(); i++) {
|
||||
if (headers[i].findn("ETag:") == 0) { // Save etag
|
||||
String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
|
||||
String new_etag = headers[i].substr(headers[i].find_char(':') + 1, headers[i].length()).strip_edges();
|
||||
String new_etag = headers[i].substr(headers[i].find_char(':') + 1).strip_edges();
|
||||
Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE);
|
||||
if (file.is_valid()) {
|
||||
file->store_line(new_etag);
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ String RenameDialog::_postprocess(const String &subject) {
|
|||
buffer += result.substr(start, 1).to_upper();
|
||||
end = start + 1;
|
||||
}
|
||||
buffer += result.substr(end, result.size() - (end + 1));
|
||||
buffer += result.substr(end);
|
||||
result = buffer.to_pascal_case();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue