diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 0e15edc29fa..c85b0866cbb 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -184,7 +184,7 @@ String ProjectSettings::localize_path(const String &p_path) const { String parent = path.substr(0, sep); String plocal = localize_path(parent); - if (plocal == "") { + if (plocal.is_empty()) { return ""; } // Only strip the starting '/' from 'path' if its parent ('plocal') ends with '/' @@ -228,13 +228,13 @@ bool ProjectSettings::get_ignore_value_in_docs(const String &p_name) const { String ProjectSettings::globalize_path(const String &p_path) const { if (p_path.begins_with("res://")) { - if (resource_path != "") { + if (!resource_path.is_empty()) { return p_path.replace("res:/", resource_path); } return p_path.replace("res://", ""); } else if (p_path.begins_with("user://")) { String data_dir = OS::get_singleton()->get_user_data_dir(); - if (data_dir != "") { + if (!data_dir.is_empty()) { return p_path.replace("user:/", data_dir); } return p_path.replace("user://", ""); @@ -456,7 +456,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b // Attempt with a user-defined main pack first - if (p_main_pack != "") { + if (!p_main_pack.is_empty()) { bool ok = _load_resource_pack(p_main_pack); ERR_FAIL_COND_V_MSG(!ok, ERR_CANT_OPEN, "Cannot open resource pack '" + p_main_pack + "'."); @@ -471,7 +471,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b String exec_path = OS::get_singleton()->get_executable_path(); - if (exec_path != "") { + if (!exec_path.is_empty()) { // We do several tests sequentially until one succeeds to find a PCK, // and if so, we attempt loading it at the end. @@ -523,11 +523,11 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b // Try to use the filesystem for files, according to OS. // (Only Android -when reading from pck- and iOS use this.) - if (OS::get_singleton()->get_resource_dir() != "") { + if (!OS::get_singleton()->get_resource_dir().is_empty()) { // OS will call ProjectSettings->get_resource_path which will be empty if not overridden! // If the OS would rather use a specific location, then it will not be empty. resource_path = OS::get_singleton()->get_resource_dir().replace("\\", "/"); - if (resource_path != "" && resource_path[resource_path.length() - 1] == '/') { + if (!resource_path.is_empty() && resource_path[resource_path.length() - 1] == '/') { resource_path = resource_path.substr(0, resource_path.length() - 1); // Chop end. } @@ -591,7 +591,7 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo Error err = _setup(p_path, p_main_pack, p_upwards, p_ignore_override); if (err == OK) { String custom_settings = GLOBAL_DEF("application/config/project_settings_override", ""); - if (custom_settings != "") { + if (!custom_settings.is_empty()) { _load_settings_text(custom_settings); } } @@ -699,21 +699,21 @@ Error ProjectSettings::_load_settings_text(const String &p_path) { return err; } - if (assign != String()) { - if (section == String() && assign == "config_version") { + if (!assign.is_empty()) { + if (section.is_empty() && assign == "config_version") { config_version = value; if (config_version > CONFIG_VERSION) { memdelete(f); ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION)); } } else { - if (section == String()) { + if (section.is_empty()) { set(assign, value); } else { set(section + "/" + assign, value); } } - } else if (next_tag.name != String()) { + } else if (!next_tag.name.is_empty()) { section = next_tag.name; } } @@ -797,7 +797,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Mapstore_32(count + 1); //store how many properties are saved, add one for custom featuers, which must always go first String key = CoreStringNames::get_singleton()->_custom_features; @@ -827,7 +827,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map>::Element *E = props.front(); E; E = E->next()) { for (String &key : E->get()) { - if (E->key() != "") { + if (!E->key().is_empty()) { key = E->key() + "/" + key; } Variant value; @@ -881,7 +881,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_line(""); file->store_string("config_version=" + itos(CONFIG_VERSION) + "\n"); - if (p_custom_features != String()) { + if (!p_custom_features.is_empty()) { file->store_string("custom_features=\"" + p_custom_features + "\"\n"); } file->store_string("\n"); @@ -891,12 +891,12 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_string("\n"); } - if (E->key() != "") { + if (!E->key().is_empty()) { file->store_string("[" + E->key() + "]\n\n"); } for (const String &F : E->get()) { String key = F; - if (E->key() != "") { + if (!E->key().is_empty()) { key = E->key() + "/" + key; } Variant value; @@ -924,7 +924,7 @@ Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other par } Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector &p_custom_features, bool p_merge_with_current) { - ERR_FAIL_COND_V_MSG(p_path == "", ERR_INVALID_PARAMETER, "Project settings save path cannot be empty."); + ERR_FAIL_COND_V_MSG(p_path.is_empty(), ERR_INVALID_PARAMETER, "Project settings save path cannot be empty."); PackedStringArray project_features = has_setting("application/config/features") ? (PackedStringArray)get_setting("application/config/features") : PackedStringArray(); // If there is no feature list currently present, force one to generate. @@ -933,7 +933,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } // Check the rendering API. const String rendering_api = has_setting("rendering/quality/driver/driver_name") ? (String)get_setting("rendering/quality/driver/driver_name") : String(); - if (rendering_api != "") { + if (!rendering_api.is_empty()) { // Add the rendering API as a project feature if it doesn't already exist. if (!project_features.has(rendering_api)) { project_features.append(rendering_api); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index e71c7648e83..161008fd35b 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1483,7 +1483,7 @@ String Directory::get_next() { ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use."); String next = d->get_next(); - while (next != "" && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) { + while (!next.is_empty() && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) { next = d->get_next(); } return next; @@ -1665,7 +1665,7 @@ String Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects) { ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant."); String ret = CryptoCore::b64_encode_str(&w[0], len); - ERR_FAIL_COND_V(ret == "", ret); + ERR_FAIL_COND_V(ret.is_empty(), ret); return ret; } @@ -1690,7 +1690,7 @@ Variant Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects) String Marshalls::raw_to_base64(const Vector &p_arr) { String ret = CryptoCore::b64_encode_str(p_arr.ptr(), p_arr.size()); - ERR_FAIL_COND_V(ret == "", ret); + ERR_FAIL_COND_V(ret.is_empty(), ret); return ret; } @@ -1714,7 +1714,7 @@ Vector Marshalls::base64_to_raw(const String &p_str) { String Marshalls::utf8_to_base64(const String &p_str) { CharString cstr = p_str.utf8(); String ret = CryptoCore::b64_encode_str((unsigned char *)cstr.get_data(), cstr.length()); - ERR_FAIL_COND_V(ret == "", ret); + ERR_FAIL_COND_V(ret.is_empty(), ret); return ret; } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index 60aa3e6be70..7b397e88a32 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -139,7 +139,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { // Cache options String variable_prefix = options["variable_prefix"]; - if (line == "") { + if (line.is_empty()) { print_line("\nDebugger Break, Reason: '" + script_lang->debug_get_error() + "'"); print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'"); print_line("Enter \"help\" for assistance."); diff --git a/core/doc_data.cpp b/core/doc_data.cpp index 4b284a30aaf..7334db5cb0f 100644 --- a/core/doc_data.cpp +++ b/core/doc_data.cpp @@ -33,7 +33,7 @@ void DocData::return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo) { if (p_retinfo.type == Variant::INT && p_retinfo.hint == PROPERTY_HINT_INT_IS_POINTER) { p_method.return_type = p_retinfo.hint_string; - if (p_method.return_type == "") { + if (p_method.return_type.is_empty()) { p_method.return_type = "void*"; } else { p_method.return_type += "*"; @@ -64,7 +64,7 @@ void DocData::argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const if (p_arginfo.type == Variant::INT && p_arginfo.hint == PROPERTY_HINT_INT_IS_POINTER) { p_argument.type = p_arginfo.hint_string; - if (p_argument.type == "") { + if (p_argument.type.is_empty()) { p_argument.type = "void*"; } else { p_argument.type += "*"; diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 03b24263700..fc74293d0d2 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -40,7 +40,7 @@ static String get_type_name(const PropertyInfo &p_info) { if (p_info.type == Variant::INT && (p_info.hint == PROPERTY_HINT_INT_IS_POINTER)) { - if (p_info.hint_string == "") { + if (p_info.hint_string.is_empty()) { return "void*"; } else { return p_info.hint_string + "*"; @@ -340,7 +340,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { int value = CoreConstants::get_global_constant_value(i); String enum_name = CoreConstants::get_global_constant_enum(i); String name = CoreConstants::get_global_constant_name(i); - if (enum_name != String()) { + if (!enum_name.is_empty()) { enum_list[enum_name].push_back(Pair(name, value)); } else { Dictionary d; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index ae7620fec4e..cfd3ac8099c 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -397,7 +397,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or } } - if (library_path == String()) { + if (library_path.is_empty()) { if (r_error) { *r_error = ERR_FILE_NOT_FOUND; } diff --git a/core/extension/native_extension_manager.cpp b/core/extension/native_extension_manager.cpp index c8755250d5f..043843ea311 100644 --- a/core/extension/native_extension_manager.cpp +++ b/core/extension/native_extension_manager.cpp @@ -115,7 +115,7 @@ void NativeExtensionManager::load_extensions() { FileAccessRef f = FileAccess::open(NativeExtension::get_extension_list_config_file(), FileAccess::READ); while (f && !f->eof_reached()) { String s = f->get_line().strip_edges(); - if (s != String()) { + if (!s.is_empty()) { LoadStatus err = load_extension(s); ERR_CONTINUE_MSG(err == LOAD_STATUS_FAILED, "Error loading extension: " + s); } diff --git a/core/input/input.cpp b/core/input/input.cpp index b72d9806814..3dfe73ab8ea 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -403,7 +403,7 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S if (p_connected) { String uidname = p_guid; - if (p_guid == "") { + if (p_guid.is_empty()) { int uidlen = MIN(p_name.length(), 16); for (int i = 0; i < uidlen; i++) { uidname = uidname + _hex_str(p_name[i]); @@ -1249,7 +1249,7 @@ void Input::parse_mapping(String p_mapping) { int idx = 1; while (++idx < entry.size()) { - if (entry[idx] == "") { + if (entry[idx].is_empty()) { continue; } @@ -1420,10 +1420,10 @@ Input::Input() { // If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides. String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG"); - if (env_mapping != "") { + if (!env_mapping.is_empty()) { Vector entries = env_mapping.split("\n"); for (int i = 0; i < entries.size(); i++) { - if (entries[i] == "") { + if (entries[i].is_empty()) { continue; } parse_mapping(entries[i]); diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index ccde8838e18..7c98fa9540a 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -360,12 +360,12 @@ String InputEventKey::as_text() const { kc = keycode_get_string(keycode); } - if (kc == String()) { + if (kc.is_empty()) { return kc; } String mods_text = InputEventWithModifiers::as_text(); - return mods_text == "" ? kc : mods_text + "+" + kc; + return mods_text.is_empty() ? kc : mods_text + "+" + kc; } String InputEventKey::to_string() { @@ -382,7 +382,7 @@ String InputEventKey::to_string() { } String mods = InputEventWithModifiers::as_text(); - mods = mods == "" ? TTR("none") : mods; + mods = mods.is_empty() ? TTR("none") : mods; return vformat("InputEventKey: keycode=%s, mods=%s, physical=%s, pressed=%s, echo=%s", kc, mods, physical, p, e); } @@ -634,7 +634,7 @@ static const char *_mouse_button_descriptions[9] = { String InputEventMouseButton::as_text() const { // Modifiers String mods_text = InputEventWithModifiers::as_text(); - String full_string = mods_text == "" ? "" : mods_text + "+"; + String full_string = mods_text.is_empty() ? "" : mods_text + "+"; // Button MouseButton idx = get_button_index(); @@ -687,7 +687,7 @@ String InputEventMouseButton::to_string() { } String mods = InputEventWithModifiers::as_text(); - mods = mods == "" ? TTR("none") : mods; + mods = mods.is_empty() ? TTR("none") : mods; // Work around the fact vformat can only take 5 substitutions but 6 need to be passed. String index_and_mods = vformat("button_index=%s, mods=%s", button_index, mods); diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 84e1313756b..183a2c3e689 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -718,7 +718,7 @@ const OrderedHashMap>> &InputMap::get_builtins_with String name = split[0]; String override_for = split.size() > 1 ? split[1] : String(); - if (override_for != String() && OS::get_singleton()->has_feature(override_for)) { + if (!override_for.is_empty() && OS::get_singleton()->has_feature(override_for)) { builtins_with_overrides[name].push_back(override_for); } } @@ -730,12 +730,12 @@ const OrderedHashMap>> &InputMap::get_builtins_with String name = split[0]; String override_for = split.size() > 1 ? split[1] : String(); - if (builtins_with_overrides.has(name) && override_for == String()) { + if (builtins_with_overrides.has(name) && override_for.is_empty()) { // Builtin has an override but this particular one is not an override, so skip. continue; } - if (override_for != String() && !OS::get_singleton()->has_feature(override_for)) { + if (!override_for.is_empty() && !OS::get_singleton()->has_feature(override_for)) { // OS does not support this override - skip. continue; } diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 33f992e153f..b2300574f87 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -183,7 +183,7 @@ Error ConfigFile::_internal_save(FileAccess *file) { if (E != values.front()) { file->store_string("\n"); } - if (E.key() != "") { + if (!E.key().is_empty()) { file->store_string("[" + E.key() + "]\n\n"); } @@ -287,9 +287,9 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) return err; } - if (assign != String()) { + if (!assign.is_empty()) { set_value(section, assign, value); - } else if (next_tag.name != String()) { + } else if (!next_tag.name.is_empty()) { section = next_tag.name; } } diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index 3bff0a3fd52..d804e674936 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -79,7 +79,7 @@ static Error _erase_recursive(DirAccess *da) { da->list_dir_begin(); String n = da->get_next(); - while (n != String()) { + while (!n.is_empty()) { if (n != "." && n != "..") { if (da->current_is_dir()) { dirs.push_back(n); @@ -183,7 +183,7 @@ String DirAccess::fix_path(String p_path) const { if (ProjectSettings::get_singleton()) { if (p_path.begins_with("res://")) { String resource_path = ProjectSettings::get_singleton()->get_resource_path(); - if (resource_path != "") { + if (!resource_path.is_empty()) { return p_path.replace_first("res:/", resource_path); } return p_path.replace_first("res://", ""); @@ -194,7 +194,7 @@ String DirAccess::fix_path(String p_path) const { case ACCESS_USERDATA: { if (p_path.begins_with("user://")) { String data_dir = OS::get_singleton()->get_user_data_dir(); - if (data_dir != "") { + if (!data_dir.is_empty()) { return p_path.replace_first("user:/", data_dir); } return p_path.replace_first("user://", ""); @@ -337,7 +337,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag String curdir = get_current_dir(); list_dir_begin(); String n = get_next(); - while (n != String()) { + while (!n.is_empty()) { if (n != "." && n != "..") { if (p_copy_links && is_link(get_current_dir().plus_file(n))) { create_link(read_link(get_current_dir().plus_file(n)), p_to + n); diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp index e6e79dff8ab..1b9c43b1550 100644 --- a/core/io/file_access.cpp +++ b/core/io/file_access.cpp @@ -127,7 +127,7 @@ String FileAccess::fix_path(const String &p_path) const { if (ProjectSettings::get_singleton()) { if (r_path.begins_with("res://")) { String resource_path = ProjectSettings::get_singleton()->get_resource_path(); - if (resource_path != "") { + if (!resource_path.is_empty()) { return r_path.replace("res:/", resource_path); } return r_path.replace("res://", ""); @@ -138,7 +138,7 @@ String FileAccess::fix_path(const String &p_path) const { case ACCESS_USERDATA: { if (r_path.begins_with("user://")) { String data_dir = OS::get_singleton()->get_user_data_dir(); - if (data_dir != "") { + if (!data_dir.is_empty()) { return r_path.replace("user:/", data_dir); } return r_path.replace("user://", ""); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index b2832b2a756..e343706e66e 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -459,7 +459,7 @@ PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) { nd = nd.simplify_path(); - if (nd == "") { + if (nd.is_empty()) { nd = "."; } diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 8a8bdf07d30..3330bb81493 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -136,7 +136,7 @@ void RotatedFileLogger::clear_old_backups() { da->list_dir_begin(); String f = da->get_next(); Set backups; - while (f != String()) { + while (!f.is_empty()) { if (!da->current_is_dir() && f.begins_with(basename) && f.get_extension() == extension && f != base_path.get_file()) { backups.insert(f); } @@ -163,7 +163,7 @@ void RotatedFileLogger::rotate_file() { if (max_files > 1) { String timestamp = Time::get_singleton()->get_datetime_string_from_system().replace(":", "."); String backup_name = base_path.get_basename() + timestamp; - if (base_path.get_extension() != String()) { + if (!base_path.get_extension().is_empty()) { backup_name += "." + base_path.get_extension(); } diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index e7d5b78d14c..7c06a354d11 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -562,7 +562,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int return err; } - if (str == String()) { + if (str.is_empty()) { r_variant = (Object *)nullptr; } else { Object *obj = ClassDB::instantiate(str); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 972076e3971..8da4e936e31 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -52,7 +52,7 @@ void Resource::set_path(const String &p_path, bool p_take_over) { return; } - if (path_cache != "") { + if (!path_cache.is_empty()) { ResourceCache::lock.write_lock(); ResourceCache::resources.erase(path_cache); ResourceCache::lock.write_unlock(); @@ -82,7 +82,7 @@ void Resource::set_path(const String &p_path, bool p_take_over) { } path_cache = p_path; - if (path_cache != "") { + if (!path_cache.is_empty()) { ResourceCache::lock.write_lock(); ResourceCache::resources[path_cache] = this; ResourceCache::lock.write_unlock(); @@ -383,7 +383,7 @@ bool Resource::is_translation_remapped() const { #ifdef TOOLS_ENABLED //helps keep IDs same number when loading/saving scenes. -1 clears ID and it Returns -1 when no id stored void Resource::set_id_for_path(const String &p_path, const String &p_id) { - if (p_id == "") { + if (p_id.is_empty()) { ResourceCache::path_cache_lock.write_lock(); ResourceCache::resource_path_cache[p_path].erase(get_path()); ResourceCache::path_cache_lock.write_unlock(); @@ -434,7 +434,7 @@ Resource::Resource() : remapped_list(this) {} Resource::~Resource() { - if (path_cache != "") { + if (!path_cache.is_empty()) { ResourceCache::lock.write_lock(); ResourceCache::resources.erase(path_cache); ResourceCache::lock.write_unlock(); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index a5a195f859d..bd040f303d4 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -727,7 +727,7 @@ Error ResourceLoaderBinary::load() { } res = RES(r); - if (path != String() && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) { + if (!path.is_empty() && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) { r->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE); //if got here because the resource with same path has different type, replace it } r->set_scene_unique_id(id); @@ -829,7 +829,7 @@ void ResourceLoaderBinary::get_dependencies(FileAccess *p_f, List *p_dep dep = external_resources[i].path; } - if (p_add_types && external_resources[i].type != String()) { + if (p_add_types && !external_resources[i].type.is_empty()) { dep += "::" + external_resources[i].type; } @@ -1026,7 +1026,7 @@ RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_origi loader.cache_mode = p_cache_mode; loader.use_sub_threads = p_use_sub_threads; loader.progress = r_progress; - String path = p_original_path != "" ? p_original_path : p_path; + String path = !p_original_path.is_empty() ? p_original_path : p_path; loader.local_path = ProjectSettings::get_singleton()->localize_path(path); loader.res_path = loader.local_path; //loader.set_local_path( Globals::get_singleton()->localize_path(p_path) ); @@ -1045,7 +1045,7 @@ RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_origi } void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String &p_type, List *p_extensions) const { - if (p_type == "") { + if (p_type.is_empty()) { get_recognized_extensions(p_extensions); return; } @@ -1979,7 +1979,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p for (RES &r : saved_resources) { if (r->is_built_in()) { - if (r->get_scene_unique_id() != "") { + if (!r->get_scene_unique_id().is_empty()) { if (used_unique_ids.has(r->get_scene_unique_id())) { r->set_scene_unique_id(""); } else { @@ -1993,7 +1993,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p int res_index = 0; for (RES &r : saved_resources) { if (r->is_built_in()) { - if (r->get_scene_unique_id() == "") { + if (r->get_scene_unique_id().is_empty()) { String new_id; while (true) { diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index cd44c537a81..fc5c434e371 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -78,8 +78,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy return err; } - if (assign != String()) { - if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) { + if (!assign.is_empty()) { + if (!path_found && assign.begins_with("path.") && r_path_and_type.path.is_empty()) { String feature = assign.get_slicec('.', 1); if (OS::get_singleton()->has_feature(feature)) { r_path_and_type.path = value; @@ -112,7 +112,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy memdelete(f); - if (r_path_and_type.path == String() || r_path_and_type.type == String()) { + if (r_path_and_type.path.is_empty() || r_path_and_type.type.is_empty()) { return ERR_FILE_CORRUPT; } return OK; @@ -158,7 +158,7 @@ void ResourceFormatImporter::get_recognized_extensions(List *p_extension } void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_type, List *p_extensions) const { - if (p_type == "") { + if (p_type.is_empty()) { get_recognized_extensions(p_extensions); return; } @@ -167,7 +167,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ for (int i = 0; i < importers.size(); i++) { String res_type = importers[i]->get_resource_type(); - if (res_type == String()) { + if (res_type.is_empty()) { continue; } @@ -246,7 +246,7 @@ int ResourceFormatImporter::get_import_order(const String &p_path) const { bool ResourceFormatImporter::handles_type(const String &p_type) const { for (int i = 0; i < importers.size(); i++) { String res_type = importers[i]->get_resource_type(); - if (res_type == String()) { + if (res_type.is_empty()) { continue; } if (ClassDB::is_parent_class(res_type, p_type)) { @@ -300,7 +300,7 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat return; } - if (assign != String()) { + if (!assign.is_empty()) { if (assign.begins_with("path.")) { r_paths->push_back(value); } else if (assign == "path") { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 2198761c2ad..f65570bd602 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -52,7 +52,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ String extension = p_path.get_extension(); List extensions; - if (p_for_type == String()) { + if (p_for_type.is_empty()) { get_recognized_extensions(&extensions); } else { get_recognized_extensions_for_type(p_for_type, &extensions); @@ -96,7 +96,7 @@ ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) con } void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List *p_extensions) const { - if (p_type == "" || handles_type(p_type)) { + if (p_type.is_empty() || handles_type(p_type)) { get_recognized_extensions(p_extensions); } } @@ -194,7 +194,7 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c continue; } found = true; - RES res = loader[i]->load(p_path, p_original_path != String() ? p_original_path : p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode); + RES res = loader[i]->load(p_path, !p_original_path.is_empty() ? p_original_path : p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode); if (res.is_null()) { continue; } @@ -289,7 +289,7 @@ Error ResourceLoader::load_threaded_request(const String &p_path, const String & thread_load_mutex->lock(); - if (p_source_resource != String()) { + if (!p_source_resource.is_empty()) { //must be loading from this resource if (!thread_load_tasks.has(p_source_resource)) { thread_load_mutex->unlock(); @@ -310,7 +310,7 @@ Error ResourceLoader::load_threaded_request(const String &p_path, const String & if (thread_load_tasks.has(local_path)) { thread_load_tasks[local_path].requests++; - if (p_source_resource != String()) { + if (!p_source_resource.is_empty()) { thread_load_tasks[p_source_resource].sub_tasks.insert(local_path); } thread_load_mutex->unlock(); @@ -354,7 +354,7 @@ Error ResourceLoader::load_threaded_request(const String &p_path, const String & ResourceCache::lock.read_unlock(); } - if (p_source_resource != String()) { + if (!p_source_resource.is_empty()) { thread_load_tasks[p_source_resource].sub_tasks.insert(local_path); } @@ -574,7 +574,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, Resour bool xl_remapped = false; String path = _path_remap(local_path, &xl_remapped); - if (path == "") { + if (path.is_empty()) { ERR_FAIL_V_MSG(RES(), "Remapping '" + local_path + "' failed."); } @@ -776,7 +776,7 @@ String ResourceLoader::get_resource_type(const String &p_path) { for (int i = 0; i < loader_count; i++) { String result = loader[i]->get_resource_type(local_path); - if (result != "") { + if (!result.is_empty()) { return result; } } diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 83d575cee8e..cb7d67a7260 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -87,7 +87,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { // In PO file, "msgctxt" appears before "msgid". If we encounter a "msgctxt", we add what we have read // and set "entered_context" to true to prevent adding twice. - if (!skip_this && msg_id != "") { + if (!skip_this && !msg_id.is_empty()) { if (status == STATUS_READING_STRING) { translation->add_message(msg_id, msg_str, msg_context); } else if (status == STATUS_READING_PLURAL) { @@ -125,7 +125,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { ERR_FAIL_V_MSG(RES(), "Unexpected 'msgid', was expecting 'msgstr' while parsing: " + path + ":" + itos(line)); } - if (msg_id != "") { + if (!msg_id.is_empty()) { if (!skip_this && !entered_context) { if (status == STATUS_READING_STRING) { translation->add_message(msg_id, msg_str, msg_context); @@ -137,7 +137,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { translation->add_plural_message(msg_id, msgs_plural, msg_context); } } - } else if (config == "") { + } else if (config.is_empty()) { config = msg_str; // Record plural rule. int p_start = config.find("Plural-Forms"); @@ -178,7 +178,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { status = STATUS_READING_STRING; } - if (l == "" || l.begins_with("#")) { + if (l.is_empty() || l.begins_with("#")) { if (l.find("fuzzy") != -1) { skip_next = true; } @@ -236,15 +236,15 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { // Add the last set of data from last iteration. if (status == STATUS_READING_STRING) { - if (msg_id != "") { + if (!msg_id.is_empty()) { if (!skip_this) { translation->add_message(msg_id, msg_str, msg_context); } - } else if (config == "") { + } else if (config.is_empty()) { config = msg_str; } } else if (status == STATUS_READING_PLURAL) { - if (!skip_this && msg_id != "") { + if (!skip_this && !msg_id.is_empty()) { if (plural_index != plural_forms - 1) { memdelete(f); ERR_FAIL_V_MSG(RES(), "Number of 'msgstr[]' doesn't match with number of plural forms: " + path + ":" + itos(line)); @@ -253,7 +253,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { } } - ERR_FAIL_COND_V_MSG(config == "", RES(), "No config found in file: " + path + "."); + ERR_FAIL_COND_V_MSG(config.is_empty(), RES(), "No config found in file: " + path + "."); Vector configs = config.split("\n"); for (int i = 0; i < configs.size(); i++) { diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index ac628acf810..bbd3b7b8dea 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -731,7 +731,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName type->constant_map[p_name] = p_constant; String enum_name = p_enum; - if (enum_name != String()) { + if (!enum_name.is_empty()) { if (enum_name.find(".") != -1) { enum_name = enum_name.get_slicec('.', 1); } diff --git a/core/object/object.cpp b/core/object/object.cpp index 3942dddf527..14d4e0bee6a 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -990,7 +990,7 @@ void Object::get_meta_list(List *p_list) const { } void Object::add_user_signal(const MethodInfo &p_signal) { - ERR_FAIL_COND_MSG(p_signal.name == "", "Signal name cannot be empty."); + ERR_FAIL_COND_MSG(p_signal.name.is_empty(), "Signal name cannot be empty."); ERR_FAIL_COND_MSG(ClassDB::has_signal(get_class_name(), p_signal.name), "User signal's name conflicts with a built-in signal of '" + get_class_name() + "'."); ERR_FAIL_COND_MSG(signal_map.has(p_signal.name), "Trying to add already existing signal '" + p_signal.name + "'."); SignalData s; @@ -1253,7 +1253,7 @@ void Object::get_signal_list(List *p_signals) const { const StringName *S = nullptr; while ((S = signal_map.next(S))) { - if (signal_map[*S].user.name != "") { + if (!signal_map[*S].user.name.is_empty()) { //user signal p_signals->push_back(signal_map[*S].user); } @@ -1680,7 +1680,7 @@ void Object::get_translatable_strings(List *p_strings) const { String text = get(E.name); - if (text == "") { + if (text.is_empty()) { continue; } diff --git a/core/object/object.h b/core/object/object.h index 795bbf27e87..fc6e6a36600 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -352,7 +352,7 @@ public: static String get_category_static() { \ String category = m_inherits::get_category_static(); \ if (_get_category != m_inherits::_get_category) { \ - if (category != "") { \ + if (!category.is_empty()) { \ category += "/"; \ } \ category += _get_category(); \ diff --git a/core/os/os.cpp b/core/os/os.cpp index 03e251880f2..c8b89319192 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -190,8 +190,8 @@ static void _OS_printres(Object *p_obj) { } void OS::print_all_resources(String p_to_file) { - ERR_FAIL_COND(p_to_file != "" && _OSPRF); - if (p_to_file != "") { + ERR_FAIL_COND(!p_to_file.is_empty() && _OSPRF); + if (!p_to_file.is_empty()) { Error err; _OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err); if (err != OK) { @@ -202,7 +202,7 @@ void OS::print_all_resources(String p_to_file) { ObjectDB::debug_objects(_OS_printres); - if (p_to_file != "") { + if (!p_to_file.is_empty()) { if (_OSPRF) { memdelete(_OSPRF); } diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index 7ab85ac9d04..bb9a44ccaf5 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -368,7 +368,7 @@ NodePath::NodePath(const String &p_path) { for (int i = from; i <= path.length(); i++) { if (path[i] == ':' || path[i] == 0) { String str = path.substr(from, i - from); - if (str == "") { + if (str.is_empty()) { if (path[i] == 0) { continue; // Allow end-of-path : } diff --git a/core/string/string_builder.cpp b/core/string/string_builder.cpp index 834c87c8459..45cc2f32807 100644 --- a/core/string/string_builder.cpp +++ b/core/string/string_builder.cpp @@ -33,7 +33,7 @@ #include StringBuilder &StringBuilder::append(const String &p_string) { - if (p_string == String()) { + if (p_string.is_empty()) { return *this; } diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp index 9024f60daec..0e3482e873f 100644 --- a/core/string/string_name.cpp +++ b/core/string/string_name.cpp @@ -310,7 +310,7 @@ StringName::StringName(const String &p_name, bool p_static) { ERR_FAIL_COND(!configured); - if (p_name == String()) { + if (p_name.is_empty()) { return; } @@ -434,7 +434,7 @@ StringName StringName::search(const char32_t *p_name) { } StringName StringName::search(const String &p_name) { - ERR_FAIL_COND_V(p_name == "", StringName()); + ERR_FAIL_COND_V(p_name.is_empty(), StringName()); MutexLock lock(mutex); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index b98aad9b58e..73f789b041d 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -1287,7 +1287,7 @@ bool TranslationServer::_load_translations(const String &p_from) { void TranslationServer::setup() { String test = GLOBAL_DEF("internationalization/locale/test", ""); test = test.strip_edges(); - if (test != "") { + if (!test.is_empty()) { set_locale(test); } else { set_locale(OS::get_singleton()->get_locale()); diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 8d1f6105783..ac8e2ece121 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4283,7 +4283,7 @@ bool String::is_valid_filename() const { return false; } - if (stripped == String()) { + if (stripped.is_empty()) { return false; } @@ -4902,7 +4902,7 @@ String DTRN(const String &p_text, const String &p_text_plural, int p_n, const St String RTR(const String &p_text, const String &p_context) { if (TranslationServer::get_singleton()) { String rtr = TranslationServer::get_singleton()->tool_translate(p_text, p_context); - if (rtr == String() || rtr == p_text) { + if (rtr.is_empty() || rtr == p_text) { return TranslationServer::get_singleton()->translate(p_text, p_context); } else { return rtr; @@ -4915,7 +4915,7 @@ String RTR(const String &p_text, const String &p_context) { String RTRN(const String &p_text, const String &p_text_plural, int p_n, const String &p_context) { if (TranslationServer::get_singleton()) { String rtr = TranslationServer::get_singleton()->tool_translate_plural(p_text, p_text_plural, p_n, p_context); - if (rtr == String() || rtr == p_text || rtr == p_text_plural) { + if (rtr.is_empty() || rtr == p_text || rtr == p_text_plural) { return TranslationServer::get_singleton()->translate_plural(p_text, p_text_plural, p_n, p_context); } else { return rtr; diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index 3c19c2c7068..47561f46216 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1598,14 +1598,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } //try path because it's a file - if (res_text == String() && res->get_path().is_resource_file()) { + if (res_text.is_empty() && res->get_path().is_resource_file()) { //external resource String path = res->get_path(); res_text = "Resource(\"" + path + "\")"; } //could come up with some sort of text - if (res_text != String()) { + if (!res_text.is_empty()) { p_store_string_func(p_store_string_ud, res_text); break; } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 4759a2b0d06..f19b4a0ce21 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1555,7 +1555,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const { p_shader->uniforms.clear(); - if (p_shader->code == String()) { + if (p_shader->code.is_empty()) { return; //just invalid, but no error } diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 1754b47c85b..be993b88e5d 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -342,7 +342,7 @@ Error DirAccessUnix::change_dir(String p_dir) { } String base = _get_root_path(); - if (base != String() && !try_dir.begins_with(base)) { + if (!base.is_empty() && !try_dir.begins_with(base)) { ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); String new_dir; new_dir.parse_utf8(real_current_dir_name); @@ -360,7 +360,7 @@ Error DirAccessUnix::change_dir(String p_dir) { String DirAccessUnix::get_current_dir(bool p_include_drive) { String base = _get_root_path(); - if (base != "") { + if (!base.is_empty()) { String bd = current_dir.replace_first(base, ""); if (bd.begins_with("/")) { return _get_root_string() + bd.substr(1, bd.length()); diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index dc21d1d8e56..75d115df9c2 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -160,7 +160,7 @@ void FileAccessUnix::close() { close_notification_func(path, flags); } - if (save_path != "") { + if (!save_path.is_empty()) { int rename_error = rename((save_path + ".tmp").utf8().get_data(), save_path.utf8().get_data()); if (rename_error && close_fail_notify) { diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 1ebc8cca5e1..f0c679b54e5 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -460,11 +460,11 @@ int OS_Unix::get_processor_count() const { String OS_Unix::get_user_data_dir() const { String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name")); - if (appname != "") { + if (!appname.is_empty()) { bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir"); if (use_custom_dir) { String custom_dir = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/custom_user_dir_name"), true); - if (custom_dir == "") { + if (custom_dir.is_empty()) { custom_dir = appname; } return get_data_path().plus_file(custom_dir); @@ -486,7 +486,7 @@ String OS_Unix::get_executable_path() const { if (len > 0) { b.parse_utf8(buf, len); } - if (b == "") { + if (b.is_empty()) { WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]"); return OS::get_executable_path(); } diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 952ee50074c..8069904655e 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -4249,7 +4249,7 @@ String RenderingDeviceVulkan::_shader_uniform_debug(RID p_shader, int p_set) { } for (int j = 0; j < shader->sets[i].uniform_info.size(); j++) { const UniformInfo &ui = shader->sets[i].uniform_info[j]; - if (ret != String()) { + if (!ret.is_empty()) { ret += "\n"; } ret += "Set: " + itos(i) + " Binding: " + itos(ui.binding) + " Type: " + shader_uniform_names[ui.type] + " Length: " + itos(ui.length); diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 3e98e36d140..aa8d7977f7f 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -133,7 +133,7 @@ Error DirAccessWindows::change_dir(String p_dir) { bool worked = (SetCurrentDirectoryW((LPCWSTR)(p_dir.utf16().get_data())) != 0); String base = _get_root_path(); - if (base != "") { + if (!base.is_empty()) { GetCurrentDirectoryW(2048, real_current_dir_name); String new_dir = String::utf16((const char16_t *)real_current_dir_name).replace("\\", "/"); if (!new_dir.begins_with(base)) { @@ -184,7 +184,7 @@ Error DirAccessWindows::make_dir(String p_dir) { String DirAccessWindows::get_current_dir(bool p_include_drive) { String base = _get_root_path(); - if (base != "") { + if (!base.is_empty()) { String bd = current_dir.replace("\\", "/").replace_first(base, ""); if (bd.begins_with("/")) { return _get_root_string() + bd.substr(1, bd.length()); @@ -196,7 +196,7 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) { if (p_include_drive) { return current_dir; } else { - if (_get_root_string() == "") { + if (_get_root_string().is_empty()) { int p = current_dir.find(":"); if (p != -1) { return current_dir.substr(p + 1); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index ff816224087..2c7b5b9be90 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -99,7 +99,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { HANDLE f = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d); if (f != INVALID_HANDLE_VALUE) { String fname = String::utf16((const char16_t *)(d.cFileName)); - if (fname != String()) { + if (!fname.is_empty()) { String base_file = path.get_file(); if (base_file != fname && base_file.findn(fname) == 0) { WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms."); @@ -142,7 +142,7 @@ void FileAccessWindows::close() { fclose(f); f = nullptr; - if (save_path != "") { + if (!save_path.is_empty()) { bool rename_error = true; int attempts = 4; while (rename_error && attempts) { diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 9df76b8657a..a8d3bfcc905 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -761,7 +761,7 @@ void ActionMapEditor::_add_action_pressed() { } void ActionMapEditor::_add_action(const String &p_name) { - if (p_name == "" || !_is_action_name_valid(p_name)) { + if (p_name.is_empty() || !_is_action_name_valid(p_name)) { show_message(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'")); return; } @@ -785,7 +785,7 @@ void ActionMapEditor::_action_edited() { return; } - if (new_name == "" || !_is_action_name_valid(new_name)) { + if (new_name.is_empty() || !_is_action_name_valid(new_name)) { ti->set_text(0, old_name); show_message(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'")); return; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index c212523c984..e7251662b70 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -650,7 +650,7 @@ public: List anims; ap->get_animation_list(&anims); for (const StringName &E : anims) { - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } @@ -659,7 +659,7 @@ public: } } - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } animations += "[stop]"; @@ -1332,7 +1332,7 @@ public: List anims; ap->get_animation_list(&anims); for (List::Element *G = anims.front(); G; G = G->next()) { - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } @@ -1341,7 +1341,7 @@ public: } } - if (animations != String()) { + if (!animations.is_empty()) { animations += ","; } animations += "[stop]"; @@ -2665,7 +2665,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (stream.is_valid()) { if (stream->get_path().is_resource_file()) { stream_name = stream->get_path().get_file(); - } else if (stream->get_name() != "") { + } else if (!stream->get_name().is_empty()) { stream_name = stream->get_name(); } else { stream_name = stream->get_class(); @@ -3657,7 +3657,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ // Let's build a node path. String path = root->get_path_to(p_node); - if (p_sub != "") { + if (!p_sub.is_empty()) { path += ":" + p_sub; } @@ -3697,7 +3697,7 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const // Let's build a node path. String path = root->get_path_to(p_node); - if (p_sub != "") { + if (!p_sub.is_empty()) { path += ":" + p_sub; } @@ -3762,7 +3762,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); for (int i = 1; i < history->get_path_size(); i++) { String prop = history->get_path_property(i); - ERR_FAIL_COND(prop == ""); + ERR_FAIL_COND(prop.is_empty()); path += ":" + prop; } @@ -3862,7 +3862,7 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari for (int i = 1; i < history->get_path_size(); i++) { String prop = history->get_path_property(i); - ERR_FAIL_COND(prop == ""); + ERR_FAIL_COND(prop.is_empty()); path += ":" + prop; } @@ -6021,7 +6021,7 @@ void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const NodePath np = p_item->get_metadata(0); Node *node = get_node(np); - if (p_filter != String() && ((String)node->get_name()).findn(p_filter) != -1) { + if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) { p_select_candidates.push_back(node); } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 371ea17c687..c024c909a35 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1534,7 +1534,7 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) { void CodeTextEditor::set_error(const String &p_error) { error->set_text(p_error); - if (p_error != "") { + if (!p_error.is_empty()) { error->set_default_cursor_shape(CURSOR_POINTING_HAND); } else { error->set_default_cursor_shape(CURSOR_ARROW); @@ -1547,7 +1547,7 @@ void CodeTextEditor::set_error_pos(int p_line, int p_column) { } void CodeTextEditor::goto_error() { - if (error->get_text() != "") { + if (!error->get_text().is_empty()) { text_editor->unfold_line(error_line); text_editor->set_caret_line(error_line); text_editor->set_caret_column(error_column); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2088a7e1c4a..4945414237f 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -111,7 +111,7 @@ public: void ConnectDialog::ok_pressed() { String method_name = dst_method->get_text(); - if (method_name == "") { + if (method_name.is_empty()) { error->set_text(TTR("Method in target node must be specified.")); error->popup_centered(); return; @@ -234,7 +234,7 @@ void ConnectDialog::_add_bind() { */ void ConnectDialog::_remove_bind() { String st = bind_editor->get_selected_path(); - if (st == "") { + if (st.is_empty()) { return; } int idx = st.get_slice("/", 1).to_int() - 1; @@ -969,7 +969,7 @@ void ConnectionsDock::update_tree() { } else if (pi.type != Variant::NIL) { tname = Variant::get_type_name(pi.type); } - signaldesc += (pi.name == "" ? String("arg " + itos(i)) : pi.name) + ": " + tname; + signaldesc += (pi.name.is_empty() ? String("arg " + itos(i)) : pi.name) + ": " + tname; argnames.push_back(pi.name + ":" + tname); } } @@ -1001,7 +1001,7 @@ void ConnectionsDock::update_tree() { if (!found) { DocTools *dd = EditorHelp::get_doc_data(); Map::Element *F = dd->class_list.find(base); - while (F && descr == String()) { + while (F && descr.is_empty()) { for (int i = 0; i < F->get().signals.size(); i++) { if (F->get().signals[i].name == signal_name.operator String()) { descr = DTR(F->get().signals[i].description); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 921c03e8ad4..6bf14df8a17 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -173,7 +173,7 @@ void CreateDialog::_update_search() { _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); const String search_text = search_box->get_text(); - bool empty_search = search_text == ""; + bool empty_search = search_text.is_empty(); // Filter all candidate results. Vector candidates; @@ -244,7 +244,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback)); } - if (search_box->get_text() != "") { + if (!search_box->get_text().is_empty()) { r_item->set_collapsed(false); } else { // Don't collapse the root node or an abstract node on the first tree level. @@ -322,7 +322,7 @@ void CreateDialog::_cleanup() { void CreateDialog::_confirmed() { String selected_item = get_selected_type(); - if (selected_item == String()) { + if (selected_item.is_empty()) { return; } @@ -642,7 +642,7 @@ void CreateDialog::_load_favorites_and_history() { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); - if (l != String()) { + if (!l.is_empty()) { favorite_list.push_back(l); } } diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 71e501056c7..4f7dc780177 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -79,7 +79,7 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { void ScriptEditorDebugger::debug_copy() { String msg = reason->get_text(); - if (msg == "") { + if (msg.is_empty()) { return; } DisplayServer::get_singleton()->clipboard_set(msg); @@ -312,7 +312,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da if (is_move_to_foreground()) { DisplayServer::get_singleton()->window_move_to_foreground(); } - if (error != "") { + if (!error.is_empty()) { tabs->set_current_tab(0); } profiler->set_enabled(false); @@ -1083,7 +1083,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n Resource *res = Object::cast_to(p_base); - if (res && res->get_path() != String()) { + if (res && !res->get_path().is_empty()) { String respath = res->get_path(); int pathid = _get_res_path_cache(respath); @@ -1113,7 +1113,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p if (p_value.is_ref()) { Ref res = p_value; - if (res.is_valid() && res->get_path() != String()) { + if (res.is_valid() && !res->get_path().is_empty()) { Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1133,13 +1133,13 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p Resource *res = Object::cast_to(p_base); - if (res && res->get_path() != String()) { + if (res && !res->get_path().is_empty()) { String respath = res->get_path(); int pathid = _get_res_path_cache(respath); if (p_value.is_ref()) { Ref res2 = p_value; - if (res2.is_valid() && res2->get_path() != String()) { + if (res2.is_valid() && !res2->get_path().is_empty()) { Array msg; msg.push_back(pathid); msg.push_back(p_property); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 7ab5d9a97ca..1cc8cc01ce0 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -75,7 +75,7 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Mapget_file_path(i); for (KeyValue &E : candidates[file]) { - if (E.value == String()) { + if (E.value.is_empty()) { E.value = path; continue; } @@ -135,7 +135,7 @@ void DependencyEditor::_fix_all() { for (KeyValue> &E : candidates) { for (const KeyValue &F : E.value) { - if (F.value != String()) { + if (!F.value.is_empty()) { remaps[F.key] = F.value; } } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index f1d427648a9..8191b343f7a 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -252,17 +252,17 @@ void DocTools::remove_from(const DocTools &p_data) { } void DocTools::add_doc(const DocData::ClassDoc &p_class_doc) { - ERR_FAIL_COND(p_class_doc.name == ""); + ERR_FAIL_COND(p_class_doc.name.is_empty()); class_list[p_class_doc.name] = p_class_doc; } void DocTools::remove_doc(const String &p_class_name) { - ERR_FAIL_COND(p_class_name == "" || !class_list.has(p_class_name)); + ERR_FAIL_COND(p_class_name.is_empty() || !class_list.has(p_class_name)); class_list.erase(p_class_name); } bool DocTools::has_doc(const String &p_class_name) { - if (p_class_name == "") { + if (p_class_name.is_empty()) { return false; } return class_list.has(p_class_name); @@ -437,7 +437,7 @@ void DocTools::generate(bool p_basic_types) { method_list.sort(); for (const MethodInfo &E : method_list) { - if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { + if (E.name.is_empty() || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } @@ -459,21 +459,21 @@ void DocTools::generate(bool p_basic_types) { } if (E.flags & METHOD_FLAG_CONST) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "const"; } if (E.flags & METHOD_FLAG_VARARG) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "vararg"; } if (E.flags & METHOD_FLAG_STATIC) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "static"; @@ -736,21 +736,21 @@ void DocTools::generate(bool p_basic_types) { DocData::return_doc_from_retinfo(method, mi.return_val); if (mi.flags & METHOD_FLAG_VARARG) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "vararg"; } if (mi.flags & METHOD_FLAG_CONST) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "const"; } if (mi.flags & METHOD_FLAG_STATIC) { - if (method.qualifiers != "") { + if (!method.qualifiers.is_empty()) { method.qualifiers += " "; } method.qualifiers += "static"; @@ -885,7 +885,7 @@ void DocTools::generate(bool p_basic_types) { md.name = mi.name; if (mi.flags & METHOD_FLAG_VARARG) { - if (md.qualifiers != "") { + if (!md.qualifiers.is_empty()) { md.qualifiers += " "; } md.qualifiers += "vararg"; @@ -1005,7 +1005,7 @@ Error DocTools::load_classes(const String &p_dir) { da->list_dir_begin(); String path; path = da->get_next(); - while (path != String()) { + while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { Ref parser = memnew(XMLParser); Error err2 = parser->open(p_dir.plus_file(path)); @@ -1035,7 +1035,7 @@ Error DocTools::erase_classes(const String &p_dir) { da->list_dir_begin(); String path; path = da->get_next(); - while (path != String()) { + while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { to_erase.push_back(path); } @@ -1236,7 +1236,7 @@ Error DocTools::_load(Ref parser) { } static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { - if (p_string == "") { + if (p_string.is_empty()) { return; } String tab; @@ -1254,15 +1254,15 @@ static void _write_method_doc(FileAccess *f, const String &p_name, Vector"); - if (m.return_type != "") { + if (!m.return_type.is_empty()) { String enum_text; - if (m.return_enum != String()) { + if (!m.return_enum.is_empty()) { enum_text = " enum=\"" + m.return_enum + "\""; } _write_string(f, 3, ""); @@ -1277,11 +1277,11 @@ static void _write_method_doc(FileAccess *f, const String &p_name, Vector"); } else { _write_string(f, 3, ""); @@ -1319,7 +1319,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map"); String header = ""); } else { _write_string(f, 2, ""); } } else { - if (k.enumeration != String()) { + if (!k.enumeration.is_empty()) { _write_string(f, 2, ""); } else { _write_string(f, 2, ""); @@ -1406,7 +1406,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map"); } else { _write_string(f, 2, ""); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 8dd3045887b..6c64c538372 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -88,7 +88,7 @@ void EditorAssetInstaller::_item_edited() { String path = item->get_metadata(0); updating = true; - if (path == String() || item == tree->get_root()) { //a dir or root + if (path.is_empty() || item == tree->get_root()) { //a dir or root _update_subitems(item, item->is_checked(0), true); } @@ -212,7 +212,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { depth--; } - if (skip || path == String()) { + if (skip || path.is_empty()) { continue; } @@ -307,7 +307,7 @@ void EditorAssetInstaller::ok_pressed() { if (status_map.has(name) && status_map[name]->is_checked(0)) { String path = status_map[name]->get_metadata(0); - if (path == String()) { // a dir + if (path.is_empty()) { // a dir String dirpath; TreeItem *t = status_map[name]; diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 86da3f89a6d..418d7d58ef6 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -340,22 +340,22 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { } void EditorAutoloadSettings::_autoload_text_submitted(const String p_name) { - if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { + if (!autoload_add_path->get_text().is_empty() && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { add_autoload->set_disabled( - p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); + p_path.is_empty() || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { String error_string; bool is_name_valid = _autoload_name_is_valid(p_name, &error_string); - add_autoload->set_disabled(autoload_add_path->get_text() == "" || !is_name_valid); + add_autoload->set_disabled(autoload_add_path->get_text().is_empty() || !is_name_valid); error_message->set_text(error_string); - error_message->set_visible(autoload_add_name->get_text() != "" && !is_name_valid); + error_message->set_visible(!autoload_add_name->get_text().is_empty() && !is_name_valid); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 1b1a7a4a097..6bc23c352a4 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -164,7 +164,7 @@ void EditorCommandPalette::_sbox_input(const Ref &p_ie) { void EditorCommandPalette::_confirmed() { TreeItem *selected_option = search_options->get_selected(); String command_key = selected_option != nullptr ? selected_option->get_metadata(0) : ""; - if (command_key != "") { + if (!command_key.is_empty()) { hide(); execute_command(command_key); } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 6fd8cb47eaa..390a2998d60 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -100,7 +100,7 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int history.resize(current + 1); //clip history to next } - if (p_property != "" && has_prev) { + if (!p_property.is_empty() && has_prev) { //add a sub property History &pr = history.write[current]; h = pr; @@ -566,7 +566,7 @@ void EditorData::remove_scene(int p_idx) { current_edited_scene--; } - if (edited_scene[p_idx].path != String()) { + if (!edited_scene[p_idx].path.is_empty()) { ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); } @@ -583,7 +583,7 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set if (p_node == p_root) { ss = p_node->get_scene_inherited_state(); - } else if (p_node->get_scene_file_path() != String()) { + } else if (!p_node->get_scene_file_path().is_empty()) { ss = p_node->get_scene_instance_state(); } @@ -647,7 +647,7 @@ bool EditorData::check_and_update_scene(int p_idx) { memdelete(edited_scene[p_idx].root); edited_scene.write[p_idx].root = new_scene; - if (new_scene->get_scene_file_path() != "") { + if (!new_scene->get_scene_file_path().is_empty()) { edited_scene.write[p_idx].path = new_scene->get_scene_file_path(); } edited_scene.write[p_idx].selection = new_selection; @@ -682,14 +682,14 @@ void EditorData::set_edited_scene_root(Node *p_root) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); edited_scene.write[current_edited_scene].root = p_root; if (p_root) { - if (p_root->get_scene_file_path() != "") { + if (!p_root->get_scene_file_path().is_empty()) { edited_scene.write[current_edited_scene].path = p_root->get_scene_file_path(); } else { p_root->set_scene_file_path(edited_scene[current_edited_scene].path); } } - if (edited_scene[current_edited_scene].path != "") { + if (!edited_scene[current_edited_scene].path.is_empty()) { edited_scene.write[current_edited_scene].file_modified_time = FileAccess::get_modified_time(edited_scene[current_edited_scene].path); } } @@ -764,7 +764,7 @@ Ref