mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Replace String comparisons with "", String() to is_empty()
Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings
This commit is contained in:
parent
31ded7e126
commit
49403cbfa0
226 changed files with 1051 additions and 1034 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue