You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Replace String comparisons with "", String() to is_empty()
Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings
This commit is contained in:
@@ -423,7 +423,7 @@ Error Main::test_setup() {
|
||||
register_server_types();
|
||||
|
||||
translation_server->setup(); //register translations, load them, etc.
|
||||
if (locale != "") {
|
||||
if (!locale.is_empty()) {
|
||||
translation_server->set_locale(locale);
|
||||
}
|
||||
translation_server->load_translations();
|
||||
@@ -1122,7 +1122,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
// Network file system needs to be configured before globals, since globals are based on the
|
||||
// 'project.godot' file which will only be available through the network if this is enabled
|
||||
FileAccessNetwork::configure();
|
||||
if (remotefs != "") {
|
||||
if (!remotefs.is_empty()) {
|
||||
file_access_network_client = memnew(FileAccessNetworkClient);
|
||||
int port;
|
||||
if (remotefs.find(":") != -1) {
|
||||
@@ -1289,7 +1289,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
PROPERTY_HINT_ENUM, "vulkan,opengl3"));
|
||||
|
||||
// if not set on the command line
|
||||
if (rendering_driver == "") {
|
||||
if (rendering_driver.is_empty()) {
|
||||
rendering_driver = GLOBAL_GET("rendering/driver/driver_name");
|
||||
}
|
||||
|
||||
@@ -1419,7 +1419,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->set_display_driver_id(display_driver_idx);
|
||||
|
||||
GLOBAL_DEF_RST_NOVAL("audio/driver/driver", AudioDriverManager::get_driver(0)->get_name());
|
||||
if (audio_driver == "") { // Specified in project.godot.
|
||||
if (audio_driver.is_empty()) { // Specified in project.godot.
|
||||
audio_driver = GLOBAL_GET("audio/driver/driver");
|
||||
}
|
||||
|
||||
@@ -1610,9 +1610,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pen_tablet/driver.windows", PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink"));
|
||||
}
|
||||
|
||||
if (tablet_driver == "") { // specified in project.godot
|
||||
if (tablet_driver.is_empty()) { // specified in project.godot
|
||||
tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");
|
||||
if (tablet_driver == "") {
|
||||
if (tablet_driver.is_empty()) {
|
||||
tablet_driver = DisplayServer::get_singleton()->tablet_get_driver_name(0);
|
||||
}
|
||||
}
|
||||
@@ -1624,7 +1624,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
||||
}
|
||||
}
|
||||
|
||||
if (DisplayServer::get_singleton()->tablet_get_current_driver() == "") {
|
||||
if (DisplayServer::get_singleton()->tablet_get_current_driver().is_empty()) {
|
||||
DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(0));
|
||||
}
|
||||
|
||||
@@ -1717,7 +1717,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
||||
Ref<Image> boot_logo;
|
||||
|
||||
if (boot_logo_image) {
|
||||
if (boot_logo_path != String()) {
|
||||
if (!boot_logo_path.is_empty()) {
|
||||
boot_logo.instantiate();
|
||||
Error load_err = ImageLoader::load_image(boot_logo_path, boot_logo);
|
||||
if (load_err) {
|
||||
@@ -1811,7 +1811,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
||||
MAIN_PRINT("Main: Load Translations and Remaps");
|
||||
|
||||
translation_server->setup(); //register translations, load them, etc.
|
||||
if (locale != "") {
|
||||
if (!locale.is_empty()) {
|
||||
translation_server->set_locale(locale);
|
||||
}
|
||||
translation_server->load_translations();
|
||||
@@ -1833,11 +1833,11 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("internationalization/rendering/text_driver", PropertyInfo(Variant::STRING, "internationalization/rendering/text_driver", PROPERTY_HINT_ENUM, text_driver_options));
|
||||
|
||||
/* Determine text driver */
|
||||
if (text_driver == "") {
|
||||
if (text_driver.is_empty()) {
|
||||
text_driver = GLOBAL_GET("internationalization/rendering/text_driver");
|
||||
}
|
||||
|
||||
if (text_driver != "") {
|
||||
if (!text_driver.is_empty()) {
|
||||
/* Load user selected text server. */
|
||||
for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) {
|
||||
if (TextServerManager::get_singleton()->get_interface(i)->get_name() == text_driver) {
|
||||
@@ -1986,7 +1986,7 @@ bool Main::start() {
|
||||
} else if (args[i] == "-p" || args[i] == "--project-manager") {
|
||||
project_manager = true;
|
||||
#endif
|
||||
} else if (args[i].length() && args[i][0] != '-' && positional_arg == "") {
|
||||
} else if (args[i].length() && args[i][0] != '-' && positional_arg.is_empty()) {
|
||||
positional_arg = args[i];
|
||||
|
||||
if (args[i].ends_with(".scn") ||
|
||||
@@ -2045,7 +2045,7 @@ bool Main::start() {
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (doc_tool_path != "") {
|
||||
if (!doc_tool_path.is_empty()) {
|
||||
// Needed to instance editor-only classes for their default values
|
||||
Engine::get_singleton()->set_editor_hint(true);
|
||||
|
||||
@@ -2124,12 +2124,12 @@ bool Main::start() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (script == "" && game_path == "" && String(GLOBAL_GET("application/run/main_scene")) != "") {
|
||||
if (script.is_empty() && game_path.is_empty() && String(GLOBAL_GET("application/run/main_scene")) != "") {
|
||||
game_path = GLOBAL_GET("application/run/main_scene");
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!editor && !project_manager && !cmdline_tool && script == "" && game_path == "") {
|
||||
if (!editor && !project_manager && !cmdline_tool && script.is_empty() && game_path.is_empty()) {
|
||||
// If we end up here, it means we didn't manage to detect what we want to run.
|
||||
// Let's throw an error gently. The code leading to this is pretty brittle so
|
||||
// this might end up triggered by valid usage, in which case we'll have to
|
||||
@@ -2145,7 +2145,7 @@ bool Main::start() {
|
||||
}
|
||||
String main_loop_type = GLOBAL_DEF("application/run/main_loop_type", "SceneTree");
|
||||
|
||||
if (script != "") {
|
||||
if (!script.is_empty()) {
|
||||
Ref<Script> script_res = ResourceLoader::load(script);
|
||||
ERR_FAIL_COND_V_MSG(script_res.is_null(), false, "Can't load script: " + script);
|
||||
|
||||
@@ -2194,7 +2194,7 @@ bool Main::start() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!main_loop && main_loop_type == "") {
|
||||
if (!main_loop && main_loop_type.is_empty()) {
|
||||
main_loop_type = "SceneTree";
|
||||
}
|
||||
|
||||
@@ -2235,7 +2235,7 @@ bool Main::start() {
|
||||
ResourceSaver::add_custom_savers();
|
||||
|
||||
if (!project_manager && !editor) { // game
|
||||
if (game_path != "" || script != "") {
|
||||
if (!game_path.is_empty() || !script.is_empty()) {
|
||||
//autoload
|
||||
OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
|
||||
|
||||
@@ -2302,7 +2302,7 @@ bool Main::start() {
|
||||
editor_node = memnew(EditorNode);
|
||||
sml->get_root()->add_child(editor_node);
|
||||
|
||||
if (_export_preset != "") {
|
||||
if (!_export_preset.is_empty()) {
|
||||
editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only);
|
||||
game_path = ""; // Do not load anything.
|
||||
}
|
||||
@@ -2417,7 +2417,7 @@ bool Main::start() {
|
||||
#endif
|
||||
|
||||
String local_game_path;
|
||||
if (game_path != "" && !project_manager) {
|
||||
if (!game_path.is_empty() && !project_manager) {
|
||||
local_game_path = game_path.replace("\\", "/");
|
||||
|
||||
if (!local_game_path.begins_with("res://")) {
|
||||
@@ -2473,7 +2473,7 @@ bool Main::start() {
|
||||
// Load SSL Certificates from Project Settings (or builtin).
|
||||
Crypto::load_default_certificates(GLOBAL_DEF("network/ssl/certificate_bundle_override", ""));
|
||||
|
||||
if (game_path != "") {
|
||||
if (!game_path.is_empty()) {
|
||||
Node *scene = nullptr;
|
||||
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path);
|
||||
if (scenedata.is_valid()) {
|
||||
@@ -2485,7 +2485,7 @@ bool Main::start() {
|
||||
|
||||
#ifdef OSX_ENABLED
|
||||
String mac_iconpath = GLOBAL_DEF("application/config/macos_native_icon", "Variant()");
|
||||
if (mac_iconpath != "") {
|
||||
if (!mac_iconpath.is_empty()) {
|
||||
DisplayServer::get_singleton()->set_native_icon(mac_iconpath);
|
||||
hasicon = true;
|
||||
}
|
||||
@@ -2493,14 +2493,14 @@ bool Main::start() {
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
String win_iconpath = GLOBAL_DEF("application/config/windows_native_icon", "Variant()");
|
||||
if (win_iconpath != "") {
|
||||
if (!win_iconpath.is_empty()) {
|
||||
DisplayServer::get_singleton()->set_native_icon(win_iconpath);
|
||||
hasicon = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
String iconpath = GLOBAL_DEF("application/config/icon", "Variant()");
|
||||
if ((iconpath != "") && (!hasicon)) {
|
||||
if ((!iconpath.is_empty()) && (!hasicon)) {
|
||||
Ref<Image> icon;
|
||||
icon.instantiate();
|
||||
if (ImageLoader::load_image(iconpath, icon) == OK) {
|
||||
|
||||
Reference in New Issue
Block a user