summaryrefslogtreecommitdiff
path: root/core/string_name.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-05-14 23:09:03 +0200
committerGitHub <noreply@github.com>2020-05-14 23:09:03 +0200
commit00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch)
tree2b1c31f45add24085b64425ce440f577424c16a1 /core/string_name.h
parent5046f666a1181675b39f156c38346525dc1c444e (diff)
parent0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff)
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'core/string_name.h')
-rw-r--r--core/string_name.h30
1 files changed, 12 insertions, 18 deletions
diff --git a/core/string_name.h b/core/string_name.h
index 762eb43610..df6b458581 100644
--- a/core/string_name.h
+++ b/core/string_name.h
@@ -36,13 +36,11 @@
#include "core/ustring.h"
struct StaticCString {
-
const char *ptr;
static StaticCString create(const char *p_ptr);
};
class StringName {
-
enum {
STRING_TABLE_BITS = 12,
@@ -68,7 +66,6 @@ class StringName {
_Data *_data = nullptr;
union _HashUnion {
-
_Data *ptr;
uint32_t hash;
};
@@ -91,7 +88,6 @@ public:
bool operator==(const char *p_name) const;
bool operator!=(const String &p_name) const;
_FORCE_INLINE_ bool operator<(const StringName &p_name) const {
-
return _data < p_name._data;
}
_FORCE_INLINE_ bool operator==(const StringName &p_name) const {
@@ -100,11 +96,11 @@ public:
return _data == p_name._data;
}
_FORCE_INLINE_ uint32_t hash() const {
-
- if (_data)
+ if (_data) {
return _data->hash;
- else
+ } else {
return 0;
+ }
}
_FORCE_INLINE_ const void *data_unique_pointer() const {
return (void *)_data;
@@ -112,12 +108,12 @@ public:
bool operator!=(const StringName &p_name) const;
_FORCE_INLINE_ operator String() const {
-
if (_data) {
- if (_data->cname)
+ if (_data->cname) {
return String(_data->cname);
- else
+ } else {
return _data->name;
+ }
}
return String();
@@ -128,24 +124,22 @@ public:
static StringName search(const String &p_name);
struct AlphCompare {
-
_FORCE_INLINE_ bool operator()(const StringName &l, const StringName &r) const {
-
const char *l_cname = l._data ? l._data->cname : "";
const char *r_cname = r._data ? r._data->cname : "";
if (l_cname) {
-
- if (r_cname)
+ if (r_cname) {
return is_str_less(l_cname, r_cname);
- else
+ } else {
return is_str_less(l_cname, r._data->name.ptr());
+ }
} else {
-
- if (r_cname)
+ if (r_cname) {
return is_str_less(l._data->name.ptr(), r_cname);
- else
+ } else {
return is_str_less(l._data->name.ptr(), r._data->name.ptr());
+ }
}
}
};