summaryrefslogtreecommitdiff
path: root/core/string
diff options
context:
space:
mode:
Diffstat (limited to 'core/string')
-rw-r--r--core/string/node_path.cpp2
-rw-r--r--core/string/string_builder.cpp2
-rw-r--r--core/string/string_name.cpp4
-rw-r--r--core/string/translation.cpp7
-rw-r--r--core/string/ustring.cpp6
5 files changed, 12 insertions, 9 deletions
diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp
index 7ab85ac9d0..bb9a44ccaf 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 834c87c845..45cc2f3280 100644
--- a/core/string/string_builder.cpp
+++ b/core/string/string_builder.cpp
@@ -33,7 +33,7 @@
#include <string.h>
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 9024f60dae..0e3482e873 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 b98aad9b58..865937e9ce 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -1092,9 +1092,12 @@ Array TranslationServer::get_loaded_locales() const {
ERR_FAIL_COND_V(t.is_null(), Array());
String l = t->get_locale();
- locales.push_back(l);
+ if (!locales.has(l)) {
+ locales.push_back(l);
+ }
}
+ locales.sort();
return locales;
}
@@ -1287,7 +1290,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 8d1f610578..ac8e2ece12 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;