From 49403cbfa0399bb4284ea5c36cc90216a0bda6ff Mon Sep 17 00:00:00 2001 From: Nathan Franke Date: Thu, 9 Dec 2021 03:42:46 -0600 Subject: Replace String comparisons with "", String() to is_empty() Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings --- core/extension/extension_api_dump.cpp | 4 ++-- core/extension/native_extension.cpp | 2 +- core/extension/native_extension_manager.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'core/extension') diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 03b2426370..fc74293d0d 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 ae7620fec4..cfd3ac8099 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 c8755250d5..043843ea31 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); } -- cgit v1.2.3