summaryrefslogtreecommitdiff
path: root/modules/visual_script/editor
diff options
context:
space:
mode:
authorNathan Franke <natfra@pm.me>2021-12-09 03:42:46 -0600
committerNathan Franke <natfra@pm.me>2021-12-09 04:48:38 -0600
commit49403cbfa0399bb4284ea5c36cc90216a0bda6ff (patch)
treecaa6c7249d35d83b288a180a4f5d7e4fd959704f /modules/visual_script/editor
parent31ded7e126b9d71ed8dddab9ffc1ce813f1a8ec2 (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 'modules/visual_script/editor')
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp18
-rw-r--r--modules/visual_script/editor/visual_script_property_selector.cpp16
2 files changed, 17 insertions, 17 deletions
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 75a1980ede..9deea79ea6 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -1328,7 +1328,7 @@ void VisualScriptEditor::_create_function_dialog() {
}
void VisualScriptEditor::_create_function() {
- String name = _validate_name((func_name_box->get_text() == "") ? "new_func" : func_name_box->get_text());
+ String name = _validate_name((func_name_box->get_text().is_empty()) ? "new_func" : func_name_box->get_text());
selected = name;
Vector2 pos = _get_available_pos();
@@ -2094,7 +2094,7 @@ Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
String type = it->get_metadata(0);
- if (type == String()) {
+ if (type.is_empty()) {
return Variant();
}
@@ -2622,7 +2622,7 @@ String VisualScriptEditor::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));
@@ -2842,7 +2842,7 @@ void VisualScriptEditor::clear_edit_menu() {
void VisualScriptEditor::_change_base_type_callback() {
String bt = select_base_type->get_selected_type();
- ERR_FAIL_COND(bt == String());
+ ERR_FAIL_COND(bt.is_empty());
undo_redo->create_action(TTR("Change Base Type"));
undo_redo->add_do_method(script.ptr(), "set_instance_base_type", bt);
undo_redo->add_undo_method(script.ptr(), "set_instance_base_type", script->get_instance_base_type());
@@ -3213,7 +3213,7 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
if (tg.type == Variant::OBJECT) {
if (tg.script.is_valid()) {
new_connect_node_select->select_from_script(tg.script, "");
- } else if (type_string != String()) {
+ } else if (!type_string.is_empty()) {
new_connect_node_select->select_from_base_type(type_string);
} else {
new_connect_node_select->select_from_base_type(n->get_base_type());
@@ -3237,7 +3237,7 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
property_info = script->get_node(port_action_node)->get_output_value_port_info(port_action_output);
}
if (tg.type == Variant::OBJECT) {
- if (property_info.type == Variant::OBJECT && property_info.hint_string != String()) {
+ if (property_info.type == Variant::OBJECT && !property_info.hint_string.is_empty()) {
new_connect_node_select->select_from_action(property_info.hint_string);
} else {
new_connect_node_select->select_from_action("");
@@ -3462,7 +3462,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint;
String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string;
- if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) {
+ if (!base_type.is_empty() && hint == PROPERTY_HINT_TYPE_STRING) {
vsfc->set_base_type(base_type);
}
if (p_text == "call" || p_text == "call_deferred") {
@@ -3497,7 +3497,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint;
String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string;
- if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) {
+ if (!base_type.is_empty() && hint == PROPERTY_HINT_TYPE_STRING) {
vsp->set_base_type(base_type);
}
}
@@ -3526,7 +3526,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
} else if (script->get_node(port_action_node).is_valid()) {
PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint;
String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string;
- if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) {
+ if (!base_type.is_empty() && hint == PROPERTY_HINT_TYPE_STRING) {
vsp->set_base_type(base_type);
}
}
diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp
index 02307b712c..9fa35d4453 100644
--- a/modules/visual_script/editor/visual_script_property_selector.cpp
+++ b/modules/visual_script/editor/visual_script_property_selector.cpp
@@ -175,7 +175,7 @@ void VisualScriptPropertySelector::_update_search() {
String set_text = set_text_raw.capitalize();
String input = search_box->get_text().capitalize();
- if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
+ if (input.is_empty() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, get_text);
item->set_metadata(0, F.name);
@@ -188,7 +188,7 @@ void VisualScriptPropertySelector::_update_search() {
item->set_metadata(2, connecting);
}
- if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
+ if (input.is_empty() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, set_text);
item->set_metadata(0, F.name);
@@ -252,7 +252,7 @@ void VisualScriptPropertySelector::_update_search() {
String desc_raw = mi.name + desc_arguments;
String desc = desc_raw.capitalize().replace("( ", "(");
- if (search_box->get_text() != String() &&
+ if (!search_box->get_text().is_empty() &&
name.findn(search_box->get_text()) == -1 &&
desc.findn(search_box->get_text()) == -1 &&
desc_raw.findn(search_box->get_text()) == -1) {
@@ -322,7 +322,7 @@ void VisualScriptPropertySelector::_update_search() {
}
void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) {
- if (search_input == String() || text.findn(search_input) != -1) {
+ if (search_input.is_empty() || text.findn(search_input) != -1) {
TreeItem *item = search_options->create_item(root);
item->set_text(0, text);
item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")));
@@ -352,7 +352,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
bool in_filter = false;
Vector<String> tx_filters = search_box->get_text().split(" ");
for (int i = 0; i < tx_filters.size(); i++) {
- if (tx_filters[i] == "") {
+ if (tx_filters[i].is_empty()) {
in_filter = true;
} else {
in_filter = false;
@@ -451,7 +451,7 @@ void VisualScriptPropertySelector::_item_selected() {
String at_class = class_type;
- while (at_class != String()) {
+ while (!at_class.is_empty()) {
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
for (int i = 0; i < E->get().properties.size(); i++) {
@@ -465,7 +465,7 @@ void VisualScriptPropertySelector::_item_selected() {
}
at_class = class_type;
- while (at_class != String()) {
+ while (!at_class.is_empty()) {
Map<String, DocData::ClassDoc>::Element *C = dd->class_list.find(at_class);
if (C) {
for (int i = 0; i < C->get().methods.size(); i++) {
@@ -521,7 +521,7 @@ void VisualScriptPropertySelector::_item_selected() {
memdelete(names);
- if (text == String()) {
+ if (text.is_empty()) {
return;
}