diff options
Diffstat (limited to 'modules')
28 files changed, 112 insertions, 113 deletions
diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index 86baec4244..26c9ef8d54 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -60,7 +60,7 @@ String find_file(const String &p_base, const String &p_file_to_find) { dir.list_dir_begin(); String n = dir.get_next(); - while (n != String()) { + while (!n.is_empty()) { if (n == "." || n == "..") { n = dir.get_next(); continue; @@ -68,7 +68,7 @@ String find_file(const String &p_base, const String &p_file_to_find) { if (dir.current_is_dir()) { // Don't use `path_to` or the returned path will be wrong. const String f = find_file(p_base + "/" + n, p_file_to_find); - if (f != "") { + if (!f.is_empty()) { return f; } } else if (n == p_file_to_find) { @@ -119,7 +119,7 @@ String FBXMaterial::find_texture_path_by_filename(const String p_filename, const dir.open("res://"); dir.list_dir_begin(); String n = dir.get_next(); - while (n != String()) { + while (!n.is_empty()) { if (n == "." || n == "..") { n = dir.get_next(); continue; @@ -136,7 +136,7 @@ String FBXMaterial::find_texture_path_by_filename(const String p_filename, const lower_n.find("picture") >= 0) { // Don't use `path_to` or the returned path will be wrong. const String f = find_file(String("res://") + n, p_filename); - if (f != "") { + if (!f.is_empty()) { return f; } } diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp index 2cc25a0690..2bb634ea56 100644 --- a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp +++ b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp @@ -368,7 +368,7 @@ MeshGeometry::MappingData<T> MeshGeometry::resolve_vertex_data_array( // UVIndex, MaterialIndex, NormalIndex, etc.. std::string indexDataElementName; - if (indexOverride != "") { + if (!indexOverride.empty()) { // Colors should become ColorIndex indexDataElementName = indexOverride; } else { diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 598f7c7ad0..ae16c22849 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -397,7 +397,7 @@ List<ClassAPI> generate_c_api_classes() { arg_type = "Variant"; } else if (arg_info.type == Variant::OBJECT) { arg_type = arg_info.class_name; - if (arg_type == "") { + if (arg_type.is_empty()) { arg_type = Variant::get_type_name(arg_info.type); } } else { diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 368eb67fa6..075977b60f 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -682,7 +682,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c ERR_CONTINUE(info.type < 0 || info.type >= Variant::VARIANT_MAX); info.name = d["name"]; - ERR_CONTINUE(info.name == ""); + ERR_CONTINUE(info.name.is_empty()); if (d.has("hint")) { info.hint = PropertyHint(d["hint"].operator int64_t()); diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 04a293ddbd..5bda9e1d53 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -232,8 +232,7 @@ bool PluginScript::instance_has(const Object *p_this) const { } bool PluginScript::has_source_code() const { - bool has = _source != ""; - return has; + return !_source.is_empty(); } String PluginScript::get_source_code() const { @@ -257,11 +256,11 @@ Error PluginScript::reload(bool p_keep_state) { _valid = false; String basedir = _path; - if (basedir == "") { + if (basedir.is_empty()) { basedir = get_path(); } - if (basedir != "") { + if (!basedir.is_empty()) { basedir = basedir.get_base_dir(); } diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp index 7faacfdcb9..c4fbff69f0 100644 --- a/modules/gdnative/pluginscript/register_types.cpp +++ b/modules/gdnative/pluginscript/register_types.cpp @@ -44,9 +44,9 @@ static List<PluginScriptLanguage *> pluginscript_languages; static Error _check_language_desc(const godot_pluginscript_language_desc *desc) { - ERR_FAIL_COND_V(!desc->name || desc->name == String(), ERR_BUG); - ERR_FAIL_COND_V(!desc->type || desc->type == String(), ERR_BUG); - ERR_FAIL_COND_V(!desc->extension || desc->extension == String(), ERR_BUG); + ERR_FAIL_COND_V(!desc->name, ERR_BUG); + ERR_FAIL_COND_V(!desc->type, ERR_BUG); + ERR_FAIL_COND_V(!desc->extension, ERR_BUG); ERR_FAIL_COND_V(!desc->recognized_extensions || !desc->recognized_extensions[0], ERR_BUG); ERR_FAIL_COND_V(!desc->init, ERR_BUG); ERR_FAIL_COND_V(!desc->finish, ERR_BUG); diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 6529154e5c..4f711dfd1e 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -413,7 +413,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l previous_column = j; // ignore if just whitespace - if (text != "") { + if (!text.is_empty()) { previous_text = text; } } @@ -509,7 +509,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - add_color_region(beg, end, comment_color, end == ""); + add_color_region(beg, end, comment_color, end.is_empty()); } /* Strings */ @@ -519,7 +519,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); - add_color_region(beg, end, string_color, end == ""); + add_color_region(beg, end, string_color, end.is_empty()); } const Ref<Script> script = _get_edited_resource(); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index b76c2c0437..4822e411ce 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -389,7 +389,7 @@ bool GDScript::instance_has(const Object *p_this) const { } bool GDScript::has_source_code() const { - return source != ""; + return !source.is_empty(); } String GDScript::get_source_code() const { @@ -458,7 +458,7 @@ void GDScript::_update_doc() { doc.is_script_doc = true; if (base.is_valid() && base->is_valid()) { - if (base->doc.name != String()) { + if (!base->doc.name.is_empty()) { doc.inherits = base->doc.name; } else { doc.inherits = base->get_instance_base_type(); @@ -472,7 +472,7 @@ void GDScript::_update_doc() { doc.tutorials = doc_tutorials; for (const KeyValue<String, DocData::EnumDoc> &E : doc_enums) { - if (E.value.description != "") { + if (!E.value.description.is_empty()) { doc.enums[E.key] = E.value.description; } } @@ -616,11 +616,11 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc String basedir = path; - if (basedir == "") { + if (basedir.is_empty()) { basedir = get_path(); } - if (basedir != "") { + if (!basedir.is_empty()) { basedir = basedir.get_base_dir(); } @@ -642,7 +642,7 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc path = c->extends_path; if (path.is_relative_path()) { String base = get_path(); - if (base == "" || base.is_relative_path()) { + if (base.is_empty() || base.is_relative_path()) { ERR_PRINT(("Could not resolve relative path for parent class: " + path).utf8().get_data()); } else { path = base.get_base_dir().plus_file(path); @@ -656,7 +656,7 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc } } - if (path != "") { + if (!path.is_empty()) { if (path != get_path()) { Ref<GDScript> bf = ResourceLoader::load(path); @@ -809,11 +809,11 @@ Error GDScript::reload(bool p_keep_state) { String basedir = path; - if (basedir == "") { + if (basedir.is_empty()) { basedir = get_path(); } - if (basedir != "") { + if (!basedir.is_empty()) { basedir = basedir.get_base_dir(); } @@ -1122,7 +1122,7 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript) String class_name; while (p_gdscript) { - if (class_name == "") { + if (class_name.is_empty()) { class_name = p_gdscript->get_script_class_name(); } else { class_name = p_gdscript->get_script_class_name() + "." + class_name; @@ -1433,7 +1433,7 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const pinfo.type = Variant::Type(d["type"].operator int()); ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX); pinfo.name = d["name"]; - ERR_CONTINUE(pinfo.name == ""); + ERR_CONTINUE(pinfo.name.is_empty()); if (d.has("hint")) { pinfo.hint = PropertyHint(d["hint"].operator int()); } diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index e99bcddeb7..d0e85147f1 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -117,7 +117,7 @@ void GDScriptCache::remove_script(const String &p_path) { Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptParserRef::Status p_status, Error &r_error, const String &p_owner) { MutexLock lock(singleton->lock); Ref<GDScriptParserRef> ref; - if (p_owner != String()) { + if (!p_owner.is_empty()) { singleton->dependencies[p_owner].insert(p_path); } if (singleton->parser_map.has(p_path)) { @@ -163,7 +163,7 @@ String GDScriptCache::get_source_code(const String &p_path) { Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const String &p_owner) { MutexLock lock(singleton->lock); - if (p_owner != String()) { + if (!p_owner.is_empty()) { singleton->dependencies[p_owner].insert(p_path); } if (singleton->full_gdscript_cache.has(p_path)) { @@ -186,7 +186,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner) { MutexLock lock(singleton->lock); - if (p_owner != String()) { + if (!p_owner.is_empty()) { singleton->dependencies[p_owner].insert(p_path); } diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index ab0fe5c37d..bba664c328 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -65,7 +65,7 @@ bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringNa } void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::Node *p_node) { - if (error != "") { + if (!error.is_empty()) { return; } @@ -2020,7 +2020,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_ if (EngineDebugger::is_active()) { String signature; // Path. - if (p_script->get_path() != String()) { + if (!p_script->get_path().is_empty()) { signature += p_script->get_path(); } // Location. @@ -2158,7 +2158,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar p_script->tool = parser->is_tool(); p_script->name = p_class->identifier ? p_class->identifier->name : ""; - if (p_script->name != "") { + if (!p_script->name.is_empty()) { if (ClassDB::class_exists(p_script->name) && ClassDB::is_class_exposed(p_script->name)) { _set_error("The class '" + p_script->name + "' shadows a native class", p_class); return ERR_ALREADY_EXISTS; @@ -2287,7 +2287,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar p_script->constants.insert(name, constant->initializer->reduced_value); #ifdef TOOLS_ENABLED p_script->member_lines[name] = constant->start_line; - if (constant->doc_description != String()) { + if (!constant->doc_description.is_empty()) { p_script->doc_constants[name] = constant->doc_description; } #endif diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 71d2699c2e..34fe2364cb 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1365,7 +1365,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context, String arg1 = args[0]; if (arg1.begins_with("/root/")) { String which = arg1.get_slice("/", 2); - if (which != "") { + if (!which.is_empty()) { // Try singletons first if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(which)) { r_type = _type_from_variant(GDScriptLanguage::get_singleton()->get_named_globals_map()[which]); @@ -2753,7 +2753,7 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t } String st = l.substr(tc, l.length()).strip_edges(); - if (st == "" || st.begins_with("#")) { + if (st.is_empty() || st.begins_with("#")) { continue; //ignore! } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index fd6bd545c9..98a93a1a53 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3100,7 +3100,7 @@ void GDScriptParser::get_class_doc_comment(int p_line, String &p_brief, String & if (!comments.has(p_line)) { return; } - ERR_FAIL_COND(p_brief != "" || p_desc != "" || p_tutorials.size() != 0); + ERR_FAIL_COND(!p_brief.is_empty() || !p_desc.is_empty() || p_tutorials.size() != 0); int line = p_line; bool in_codeblock = false; @@ -3132,7 +3132,7 @@ void GDScriptParser::get_class_doc_comment(int p_line, String &p_brief, String & String striped_line = doc_line.strip_edges(); // Set the read mode. - if (striped_line.begins_with("@desc:") && p_desc == "") { + if (striped_line.begins_with("@desc:") && p_desc.is_empty()) { mode = DESC; striped_line = striped_line.trim_prefix("@desc:"); in_codeblock = _in_codeblock(doc_line, in_codeblock); diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 6dd8c3e0dd..be9e5df2b0 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -755,7 +755,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (!valid) { String v = index->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; @@ -785,7 +785,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (!valid) { String v = index->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; @@ -817,7 +817,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (oob) { String v = index->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; @@ -848,7 +848,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (!valid) { String v = index->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; @@ -884,7 +884,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (!valid) { String v = key->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(key) + "'"; @@ -917,7 +917,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (oob) { String v = index->operator String(); - if (v != "") { + if (!v.is_empty()) { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; @@ -3295,20 +3295,20 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a //error // function, file, line, error, explanation String err_file; - if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->path != "") { + if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->path.is_empty()) { err_file = p_instance->script->path; } else if (script) { err_file = script->path; } - if (err_file == "") { + if (err_file.is_empty()) { err_file = "<built-in>"; } String err_func = name; - if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->name != "") { + if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->name.is_empty()) { err_func = p_instance->script->name + "." + err_func; } int err_line = line; - if (err_text == "") { + if (err_text.is_empty()) { err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report)."; } diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index d2e71efee7..21883b3c6e 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -267,7 +267,7 @@ bool GDScriptTestRunner::generate_class_index() { String base_type; String class_name = GDScriptLanguage::get_singleton()->get_global_class_name(test.get_source_file(), &base_type); - if (class_name == String()) { + if (class_name.is_empty()) { continue; } ERR_FAIL_COND_V_MSG(ScriptServer::is_global_class(class_name), false, diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index dd545ff431..69bf59f848 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -120,7 +120,7 @@ static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage preamble += "#define has_VK_KHR_multiview 1\n"; } - if (preamble != "") { + if (!preamble.empty()) { shader.setPreamble(preamble.c_str()); } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index cf37f75d05..c2169c6335 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -885,11 +885,11 @@ void GridMapEditor::update_palette() { String name = mesh_library->get_item_name(id); Ref<Texture2D> preview = mesh_library->get_item_preview(id); - if (name == "") { + if (name.is_empty()) { name = "#" + itos(id); } - if (filter != "" && !filter.is_subsequence_ofi(name)) { + if (!filter.is_empty() && !filter.is_subsequence_ofi(name)) { continue; } diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp index 32a31aa764..ea28d0c0c8 100644 --- a/modules/hdr/image_loader_hdr.cpp +++ b/modules/hdr/image_loader_hdr.cpp @@ -41,7 +41,7 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force while (true) { String line = f->get_line(); ERR_FAIL_COND_V(f->eof_reached(), ERR_FILE_UNRECOGNIZED); - if (line == "") { // empty line indicates end of header + if (line.is_empty()) { // empty line indicates end of header break; } if (line.begins_with("FORMAT=")) { // leave option to implement other commands diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index 2522f1bb11..9d985e16d4 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -310,7 +310,7 @@ void CryptoMbedTLS::load_default_certificates(String p_path) { default_certs = memnew(X509CertificateMbedTLS); ERR_FAIL_COND(default_certs == nullptr); - if (p_path != "") { + if (!p_path.is_empty()) { // Use certs defined in project settings. default_certs->load(p_path); } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index 7433c865f5..61d0890288 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -155,7 +155,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr dir_access->list_dir_begin(); String filename = dir_access->get_next(); - while (filename != "") { + while (!filename.is_empty()) { if (filename == "." || filename == "..") { filename = dir_access->get_next(); continue; diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index aa8978a430..e2908a8a66 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -4263,7 +4263,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star } hb_buffer_set_script(p_sd->hb_buffer, p_script); - if (p_sd->spans[p_span].language != String()) { + if (!p_sd->spans[p_span].language.is_empty()) { hb_language_t lang = hb_language_from_string(p_sd->spans[p_span].language.ascii().get_data(), -1); hb_buffer_set_language(p_sd->hb_buffer, lang); } @@ -4971,12 +4971,12 @@ void TextServerAdvanced::_insert_num_systems_lang() { } String TextServerAdvanced::format_number(const String &p_string, const String &p_language) const { - const StringName lang = (p_language == "") ? TranslationServer::get_singleton()->get_tool_locale() : p_language; + const StringName lang = (p_language.is_empty()) ? TranslationServer::get_singleton()->get_tool_locale() : p_language; String res = p_string; for (int i = 0; i < num_systems.size(); i++) { if (num_systems[i].lang.has(lang)) { - if (num_systems[i].digits == String()) { + if (num_systems[i].digits.is_empty()) { return p_string; } res.replace("e", num_systems[i].exp); @@ -4996,12 +4996,12 @@ String TextServerAdvanced::format_number(const String &p_string, const String &p } String TextServerAdvanced::parse_number(const String &p_string, const String &p_language) const { - const StringName lang = (p_language == "") ? TranslationServer::get_singleton()->get_tool_locale() : p_language; + const StringName lang = (p_language.is_empty()) ? TranslationServer::get_singleton()->get_tool_locale() : p_language; String res = p_string; for (int i = 0; i < num_systems.size(); i++) { if (num_systems[i].lang.has(lang)) { - if (num_systems[i].digits == String()) { + if (num_systems[i].digits.is_empty()) { return p_string; } res.replace(num_systems[i].exp, "e"); @@ -5024,11 +5024,11 @@ String TextServerAdvanced::parse_number(const String &p_string, const String &p_ } String TextServerAdvanced::percent_sign(const String &p_language) const { - const StringName lang = (p_language == "") ? TranslationServer::get_singleton()->get_tool_locale() : p_language; + const StringName lang = (p_language.is_empty()) ? TranslationServer::get_singleton()->get_tool_locale() : p_language; for (int i = 0; i < num_systems.size(); i++) { if (num_systems[i].lang.has(lang)) { - if (num_systems[i].percent_sign == String()) { + if (num_systems[i].percent_sign.is_empty()) { return "%"; } return num_systems[i].percent_sign; 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; } diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 34d8c0b1e6..63bd9bbee4 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1665,8 +1665,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p String err_func = p_method; int err_line = current_node_id; // Not a line but it works as one. - if (node && (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD || error_str == String())) { - if (error_str != String()) { + if (node && (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD || error_str.is_empty())) { + if (!error_str.is_empty()) { error_str += " "; } @@ -2379,7 +2379,7 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String for (int i = 0; i < node->input_port_count; i++) { String name = node->get_base_node()->get_input_value_port_info(i).name; - if (name == String()) { + if (name.is_empty()) { name = "in_" + itos(i); } @@ -2399,7 +2399,7 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String for (int i = 0; i < node->output_port_count; i++) { String name = node->get_base_node()->get_output_value_port_info(i).name; - if (name == String()) { + if (name.is_empty()) { name = "out_" + itos(i); } diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index 62a4f465cb..278d806595 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -724,7 +724,7 @@ String VisualScriptTypeCast::get_caption() const { } String VisualScriptTypeCast::get_text() const { - if (script != String()) { + if (!script.is_empty()) { return "Is " + script.get_file() + "?"; } else { return "Is " + base_type + "?"; @@ -762,7 +762,7 @@ String VisualScriptTypeCast::get_base_script() const { VisualScriptTypeCast::TypeGuess VisualScriptTypeCast::guess_output_type(TypeGuess *p_inputs, int p_output) const { TypeGuess tg; tg.type = Variant::OBJECT; - if (script != String()) { + if (!script.is_empty()) { tg.script = ResourceLoader::load(script); } //if (!tg.script.is_valid()) { @@ -793,7 +793,7 @@ public: return 0; } - if (script != String()) { + if (!script.is_empty()) { Ref<Script> obj_script = obj->get_script(); if (!obj_script.is_valid()) { return 1; //well, definitely not the script because object we got has no script. @@ -853,7 +853,7 @@ void VisualScriptTypeCast::_bind_methods() { String script_ext_hint; for (const String &E : script_extensions) { - if (script_ext_hint != String()) { + if (!script_ext_hint.is_empty()) { script_ext_hint += ","; } script_ext_hint += "*." + E; diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index a2ad38bf01..651464dfdb 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -370,7 +370,7 @@ void VisualScriptFunctionCall::_update_method_cache() { } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -539,7 +539,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const property.hint = PROPERTY_HINT_ENUM; String sl; for (const Engine::Singleton &E : names) { - if (sl != String()) { + if (!sl.is_empty()) { sl += ","; } sl += E.name; @@ -580,7 +580,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -684,7 +684,7 @@ void VisualScriptFunctionCall::_bind_methods() { String script_ext_hint; for (const String &E : script_extensions) { - if (script_ext_hint != String()) { + if (!script_ext_hint.is_empty()) { script_ext_hint += ","; } script_ext_hint += "*." + E; @@ -1161,7 +1161,7 @@ void VisualScriptPropertySet::_update_cache() { } } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -1321,7 +1321,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -1361,7 +1361,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_ENUM; property.hint_string = options; property.type = Variant::STRING; - if (options == "") { + if (options.is_empty()) { property.usage = PROPERTY_USAGE_NONE; //hide if type has no usable index } } @@ -1411,7 +1411,7 @@ void VisualScriptPropertySet::_bind_methods() { String script_ext_hint; for (const String &E : script_extensions) { - if (script_ext_hint != String()) { + if (!script_ext_hint.is_empty()) { script_ext_hint += ","; } script_ext_hint += "*." + E; @@ -1847,7 +1847,7 @@ void VisualScriptPropertyGet::_update_cache() { } } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -2027,7 +2027,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; - if (base_script != String()) { + if (!base_script.is_empty()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } @@ -2066,7 +2066,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_ENUM; property.hint_string = options; property.type = Variant::STRING; - if (options == "") { + if (options.is_empty()) { property.usage = PROPERTY_USAGE_NONE; //hide if type has no usable index } } @@ -2113,7 +2113,7 @@ void VisualScriptPropertyGet::_bind_methods() { String script_ext_hint; for (const String &E : script_extensions) { - if (script_ext_hint != String()) { + if (!script_ext_hint.is_empty()) { script_ext_hint += ","; } script_ext_hint += "." + E; @@ -2324,7 +2324,7 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { String ml; for (const StringName &E : sigs) { - if (ml != String()) { + if (!ml.is_empty()) { ml += ","; } ml += E; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index b0af030981..bb4c83bd24 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1307,7 +1307,7 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const { String vhint; for (const StringName &E : vars) { - if (vhint != String()) { + if (!vhint.is_empty()) { vhint += ","; } @@ -1417,7 +1417,7 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const { String vhint; for (const StringName &E : vars) { - if (vhint != String()) { + if (!vhint.is_empty()) { vhint += ","; } @@ -1615,7 +1615,7 @@ PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const { pinfo.hint_string = preload->get_class(); if (preload->get_path().is_resource_file()) { pinfo.name = preload->get_path(); - } else if (preload->get_name() != String()) { + } else if (!preload->get_name().is_empty()) { pinfo.name = preload->get_name(); } else { pinfo.name = preload->get_class(); @@ -1994,7 +1994,7 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const property.hint_string = ""; for (const String &E : constants) { - if (property.hint_string != String()) { + if (!property.hint_string.is_empty()) { property.hint_string += ","; } property.hint_string += E; @@ -2132,7 +2132,7 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c } property.hint_string = ""; for (const StringName &E : constants) { - if (property.hint_string != String()) { + if (!property.hint_string.is_empty()) { property.hint_string += ","; } property.hint_string += String(E); @@ -2363,7 +2363,7 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con continue; //skip these, too simple named } - if (cc != String()) { + if (!cc.is_empty()) { cc += ","; } cc += E.name; @@ -3147,7 +3147,7 @@ String VisualScriptSubCall::get_caption() const { String VisualScriptSubCall::get_text() const { Ref<Script> script = get_script(); if (script.is_valid()) { - if (script->get_name() != String()) { + if (!script->get_name().is_empty()) { return script->get_name(); } if (script->get_path().is_resource_file()) { @@ -3786,7 +3786,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const { al.sort(); for (int i = 0; i < al.size(); i++) { - if (actions != String()) { + if (!actions.is_empty()) { actions += ","; } actions += al[i]; diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index 4b89c9ccd0..c5d17e5a11 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -449,7 +449,7 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { String ml; for (const String &E : mstring) { - if (ml != String()) { + if (!ml.is_empty()) { ml += ","; } ml += E; diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 514b2d055f..a3d0d3554f 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -83,11 +83,11 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols, St break; } // Found a protocol - if (protocol != "") { + if (!protocol.is_empty()) { break; } } - if (protocol == "") { // Invalid protocol(s) requested + if (protocol.is_empty()) { // Invalid protocol(s) requested return false; } } else if (p_protocols.size() > 0) { // No protocol requested, but we need one @@ -138,7 +138,7 @@ Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uin s += "Upgrade: websocket\r\n"; s += "Connection: Upgrade\r\n"; s += "Sec-WebSocket-Accept: " + WSLPeer::compute_key_response(key) + "\r\n"; - if (protocol != "") { + if (!protocol.is_empty()) { s += "Sec-WebSocket-Protocol: " + protocol + "\r\n"; } s += "\r\n"; |