Browse Source

Simplify `StringName` to `bool` conversions.
Move `mutex` include of `string_name.h` to `string_name.cpp`.

Lukas Tenbrink 4 tháng trước cách đây
mục cha
commit
91362a61da

+ 1 - 8
core/string/string_name.cpp

@@ -30,6 +30,7 @@
 
 #include "string_name.h"
 
+#include "core/os/mutex.h"
 #include "core/os/os.h"
 #include "core/string/print_string.h"
 
@@ -176,14 +177,6 @@ int StringName::length() const {
 	return 0;
 }
 
-bool StringName::is_empty() const {
-	if (_data) {
-		return _data->name.is_empty();
-	}
-
-	return true;
-}
-
 StringName &StringName::operator=(const StringName &p_name) {
 	if (this == &p_name) {
 		return *this;

+ 2 - 3
core/string/string_name.h

@@ -30,7 +30,6 @@
 
 #pragma once
 
-#include "core/os/mutex.h"
 #include "core/string/ustring.h"
 #include "core/templates/safe_refcount.h"
 
@@ -78,7 +77,7 @@ class StringName {
 	StringName(_Data *p_data) { _data = p_data; }
 
 public:
-	explicit operator bool() const { return _data && !_data->name.is_empty(); }
+	_FORCE_INLINE_ explicit operator bool() const { return _data; }
 
 	bool operator==(const String &p_name) const;
 	bool operator==(const char *p_name) const;
@@ -88,7 +87,7 @@ public:
 	const char32_t *get_data() const { return _data ? _data->name.ptr() : U""; }
 	char32_t operator[](int p_index) const;
 	int length() const;
-	bool is_empty() const;
+	_FORCE_INLINE_ bool is_empty() const { return !_data; }
 
 	_FORCE_INLINE_ bool is_node_unique_name() const {
 		if (!_data) {

+ 1 - 0
modules/jolt_physics/spaces/jolt_contact_listener_3d.h

@@ -30,6 +30,7 @@
 
 #pragma once
 
+#include "core/os/mutex.h"
 #include "core/templates/hash_map.h"
 #include "core/templates/hash_set.h"
 #include "core/templates/hashfuncs.h"