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:
@@ -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 :
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1287,7 +1287,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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user