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
|
@ -101,7 +101,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
|
|||
parent_name->set_text(p_base_name);
|
||||
parent_name->deselect();
|
||||
|
||||
if (p_base_path != "") {
|
||||
if (!p_base_path.is_empty()) {
|
||||
initial_bp = p_base_path.get_basename();
|
||||
file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension());
|
||||
current_language = language_menu->get_selected();
|
||||
|
@ -163,10 +163,10 @@ bool ScriptCreateDialog::_validate_class(const String &p_string) {
|
|||
String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must_exist) {
|
||||
String p = p_path.strip_edges();
|
||||
|
||||
if (p == "") {
|
||||
if (p.is_empty()) {
|
||||
return TTR("Path is empty.");
|
||||
}
|
||||
if (p.get_file().get_basename() == "") {
|
||||
if (p.get_file().get_basename().is_empty()) {
|
||||
return TTR("Filename is empty.");
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must
|
|||
|
||||
/* Let ScriptLanguage do custom validation */
|
||||
String path_error = ScriptServer::get_language(language_menu->get_selected())->validate_path(p);
|
||||
if (path_error != "") {
|
||||
if (!path_error.is_empty()) {
|
||||
return path_error;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ void ScriptCreateDialog::_create_new() {
|
|||
String cname_param = _get_class_name();
|
||||
|
||||
Ref<Script> scr;
|
||||
if (script_template != "") {
|
||||
if (!script_template.is_empty()) {
|
||||
scr = ResourceLoader::load(script_template);
|
||||
if (scr.is_null()) {
|
||||
alert->set_text(vformat(TTR("Error loading template '%s'"), script_template));
|
||||
|
@ -358,7 +358,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
|
|||
String selected_ext = "." + language->get_extension();
|
||||
String path = file_path->get_text();
|
||||
String extension = "";
|
||||
if (path != "") {
|
||||
if (!path.is_empty()) {
|
||||
if (path.find(".") != -1) {
|
||||
extension = path.get_extension();
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
|||
is_new_script_created = true;
|
||||
|
||||
String path_error = _validate_path(p_path, false);
|
||||
if (path_error != "") {
|
||||
if (!path_error.is_empty()) {
|
||||
_msg_path_valid(false, path_error);
|
||||
_update_dialog();
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue