diff options
author | Nathan Franke <natfra@pm.me> | 2021-12-09 03:42:46 -0600 |
---|---|---|
committer | Nathan Franke <natfra@pm.me> | 2021-12-09 04:48:38 -0600 |
commit | 49403cbfa0399bb4284ea5c36cc90216a0bda6ff (patch) | |
tree | caa6c7249d35d83b288a180a4f5d7e4fd959704f /editor/plugins/script_text_editor.cpp | |
parent | 31ded7e126b9d71ed8dddab9ffc1ce813f1a8ec2 (diff) |
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
Diffstat (limited to 'editor/plugins/script_text_editor.cpp')
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 36bab83630..d5af7c5b38 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -205,7 +205,7 @@ void ScriptTextEditor::_set_theme_for_script() { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); if (!text_edit->has_string_delimiter(beg)) { - text_edit->add_string_delimiter(beg, end, end == ""); + text_edit->add_string_delimiter(beg, end, end.is_empty()); } if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) { @@ -219,7 +219,7 @@ void ScriptTextEditor::_set_theme_for_script() { for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - text_edit->add_comment_delimiter(beg, end, end == ""); + text_edit->add_comment_delimiter(beg, end, end.is_empty()); if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) { text_edit->add_auto_brace_completion_pair(beg, end); @@ -381,7 +381,7 @@ String ScriptTextEditor::get_name() { name = TTR("[unsaved]"); } else if (script->is_built_in()) { const String &script_name = script->get_name(); - if (script_name != "") { + if (!script_name.is_empty()) { // If the built-in script has a custom resource name defined, // display the built-in script name as follows: `ResourceName (scene_file.tscn)` name = vformat("%s (%s)", script_name, name.get_slice("::", 0)); @@ -990,7 +990,7 @@ void ScriptTextEditor::_gutter_clicked(int p_line, int p_gutter) { } String method = code_editor->get_text_editor()->get_line_gutter_metadata(p_line, p_gutter); - if (method == "") { + if (method.is_empty()) { return; } @@ -1137,7 +1137,7 @@ void ScriptTextEditor::_edit_option(int p_op) { if (expression.parse(line) == OK) { Variant result = expression.execute(Array(), Variant(), false); - if (expression.get_error_text() == "") { + if (expression.get_error_text().is_empty()) { results.push_back(whitespace + result.get_construct_string()); } else { results.push_back(line); @@ -1263,19 +1263,19 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case HELP_CONTEXTUAL: { String text = tx->get_selected_text(); - if (text == "") { + if (text.is_empty()) { text = tx->get_word_under_caret(); } - if (text != "") { + if (!text.is_empty()) { emit_signal(SNAME("request_help"), text); } } break; case LOOKUP_SYMBOL: { String text = tx->get_word_under_caret(); - if (text == "") { + if (text.is_empty()) { text = tx->get_selected_text(); } - if (text != "") { + if (!text.is_empty()) { _lookup_symbol(text, tx->get_caret_line(), tx->get_caret_column()); } } break; @@ -1560,10 +1560,10 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } String word_at_pos = tx->get_word_at_pos(local_pos); - if (word_at_pos == "") { + if (word_at_pos.is_empty()) { word_at_pos = tx->get_word_under_caret(); } - if (word_at_pos == "") { + if (word_at_pos.is_empty()) { word_at_pos = tx->get_selected_text(); } |