diff options
author | Nathan Franke <natfra@pm.me> | 2021-12-09 03:42:46 -0600 |
---|---|---|
committer | Nathan Franke <natfra@pm.me> | 2021-12-09 04:48:38 -0600 |
commit | 49403cbfa0399bb4284ea5c36cc90216a0bda6ff (patch) | |
tree | caa6c7249d35d83b288a180a4f5d7e4fd959704f /platform/windows | |
parent | 31ded7e126b9d71ed8dddab9ffc1ce813f1a8ec2 (diff) |
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 2 | ||||
-rw-r--r-- | platform/windows/export/export_plugin.cpp | 30 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 6 |
3 files changed, 19 insertions, 19 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 9fe15366f4..2878981078 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1565,7 +1565,7 @@ String DisplayServerWindows::keyboard_get_layout_name(int p_index) const { GetKeyboardLayoutList(layout_count, layouts); String ret = _get_full_layout_name_from_registry(layouts[p_index]); // Try reading full name from Windows registry, fallback to locale name if failed (e.g. on Wine). - if (ret == String()) { + if (ret.is_empty()) { WCHAR buf[LOCALE_NAME_MAX_LENGTH]; memset(buf, 0, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR)); LCIDToLocaleName(MAKELCID(LOWORD(layouts[p_index]), SORT_DEFAULT), buf, LOCALE_NAME_MAX_LENGTH, 0); diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index 165e86c066..5a1cdb0962 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -82,7 +82,7 @@ void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_optio void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) { String rcedit_path = EditorSettings::get_singleton()->get("export/windows/rcedit"); - if (rcedit_path == String()) { + if (rcedit_path.is_empty()) { return; } @@ -95,12 +95,12 @@ void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> // On non-Windows we need WINE to run rcedit String wine_path = EditorSettings::get_singleton()->get("export/windows/wine"); - if (wine_path != String() && !FileAccess::exists(wine_path)) { + if (!wine_path.is_empty() && !FileAccess::exists(wine_path)) { ERR_PRINT("Could not find wine executable at " + wine_path + ", no icon or app information data will be included."); return; } - if (wine_path == String()) { + if (wine_path.is_empty()) { wine_path = "wine"; // try to run wine from PATH } #endif @@ -117,39 +117,39 @@ void EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> List<String> args; args.push_back(p_path); - if (icon_path != String()) { + if (!icon_path.is_empty()) { args.push_back("--set-icon"); args.push_back(icon_path); } - if (file_verion != String()) { + if (!file_verion.is_empty()) { args.push_back("--set-file-version"); args.push_back(file_verion); } - if (product_version != String()) { + if (!product_version.is_empty()) { args.push_back("--set-product-version"); args.push_back(product_version); } - if (company_name != String()) { + if (!company_name.is_empty()) { args.push_back("--set-version-string"); args.push_back("CompanyName"); args.push_back(company_name); } - if (product_name != String()) { + if (!product_name.is_empty()) { args.push_back("--set-version-string"); args.push_back("ProductName"); args.push_back(product_name); } - if (file_description != String()) { + if (!file_description.is_empty()) { args.push_back("--set-version-string"); args.push_back("FileDescription"); args.push_back(file_description); } - if (copyright != String()) { + if (!copyright.is_empty()) { args.push_back("--set-version-string"); args.push_back("LegalCopyright"); args.push_back(copyright); } - if (trademarks != String()) { + if (!trademarks.is_empty()) { args.push_back("--set-version-string"); args.push_back("LegalTrademarks"); args.push_back(trademarks); @@ -169,20 +169,20 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p #ifdef WINDOWS_ENABLED String signtool_path = EditorSettings::get_singleton()->get("export/windows/signtool"); - if (signtool_path != String() && !FileAccess::exists(signtool_path)) { + if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) { ERR_PRINT("Could not find signtool executable at " + signtool_path + ", aborting."); return ERR_FILE_NOT_FOUND; } - if (signtool_path == String()) { + if (signtool_path.is_empty()) { signtool_path = "signtool"; // try to run signtool from PATH } #else String signtool_path = EditorSettings::get_singleton()->get("export/windows/osslsigncode"); - if (signtool_path != String() && !FileAccess::exists(signtool_path)) { + if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) { ERR_PRINT("Could not find osslsigncode executable at " + signtool_path + ", aborting."); return ERR_FILE_NOT_FOUND; } - if (signtool_path == String()) { + if (signtool_path.is_empty()) { signtool_path = "osslsigncode"; // try to run signtool from PATH } #endif diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 6a0a4790fc..d2cf9a62ee 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -606,7 +606,7 @@ String OS_Windows::get_locale() const { wl++; } - if (neutral != "") + if (!neutral.is_empty()) return String(neutral).replace("-", "_"); return "en"; @@ -757,11 +757,11 @@ String OS_Windows::get_system_dir(SystemDir p_dir, bool p_shared_storage) const String OS_Windows::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).replace("\\", "/"); |