Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@ -33,7 +33,6 @@
|
||||
#include "core/print_string.h"
|
||||
|
||||
void NodePath::_update_hash_cache() const {
|
||||
|
||||
uint32_t h = data->absolute ? 1 : 0;
|
||||
int pc = data->path.size();
|
||||
const StringName *sn = data->path.ptr();
|
||||
@ -51,7 +50,6 @@ void NodePath::_update_hash_cache() const {
|
||||
}
|
||||
|
||||
void NodePath::prepend_period() {
|
||||
|
||||
if (data->path.size() && data->path[0].operator String() != ".") {
|
||||
data->path.insert(0, ".");
|
||||
data->hash_cache_valid = false;
|
||||
@ -59,51 +57,43 @@ void NodePath::prepend_period() {
|
||||
}
|
||||
|
||||
bool NodePath::is_absolute() const {
|
||||
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
return data->absolute;
|
||||
}
|
||||
int NodePath::get_name_count() const {
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
return data->path.size();
|
||||
}
|
||||
StringName NodePath::get_name(int p_idx) const {
|
||||
|
||||
ERR_FAIL_COND_V(!data, StringName());
|
||||
ERR_FAIL_INDEX_V(p_idx, data->path.size(), StringName());
|
||||
return data->path[p_idx];
|
||||
}
|
||||
|
||||
int NodePath::get_subname_count() const {
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
return data->subpath.size();
|
||||
}
|
||||
StringName NodePath::get_subname(int p_idx) const {
|
||||
|
||||
ERR_FAIL_COND_V(!data, StringName());
|
||||
ERR_FAIL_INDEX_V(p_idx, data->subpath.size(), StringName());
|
||||
return data->subpath[p_idx];
|
||||
}
|
||||
|
||||
void NodePath::unref() {
|
||||
|
||||
if (data && data->refcount.unref()) {
|
||||
|
||||
memdelete(data);
|
||||
}
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
bool NodePath::operator==(const NodePath &p_path) const {
|
||||
|
||||
if (data == p_path.data)
|
||||
return true;
|
||||
|
||||
@ -129,7 +119,6 @@ bool NodePath::operator==(const NodePath &p_path) const {
|
||||
const StringName *r_path_ptr = p_path.data->path.ptr();
|
||||
|
||||
for (int i = 0; i < path_size; i++) {
|
||||
|
||||
if (l_path_ptr[i] != r_path_ptr[i])
|
||||
return false;
|
||||
}
|
||||
@ -138,7 +127,6 @@ bool NodePath::operator==(const NodePath &p_path) const {
|
||||
const StringName *r_subpath_ptr = p_path.data->subpath.ptr();
|
||||
|
||||
for (int i = 0; i < subpath_size; i++) {
|
||||
|
||||
if (l_subpath_ptr[i] != r_subpath_ptr[i])
|
||||
return false;
|
||||
}
|
||||
@ -146,25 +134,21 @@ bool NodePath::operator==(const NodePath &p_path) const {
|
||||
return true;
|
||||
}
|
||||
bool NodePath::operator!=(const NodePath &p_path) const {
|
||||
|
||||
return (!(*this == p_path));
|
||||
}
|
||||
|
||||
void NodePath::operator=(const NodePath &p_path) {
|
||||
|
||||
if (this == &p_path)
|
||||
return;
|
||||
|
||||
unref();
|
||||
|
||||
if (p_path.data && p_path.data->refcount.ref()) {
|
||||
|
||||
data = p_path.data;
|
||||
}
|
||||
}
|
||||
|
||||
NodePath::operator String() const {
|
||||
|
||||
if (!data)
|
||||
return String();
|
||||
|
||||
@ -173,14 +157,12 @@ NodePath::operator String() const {
|
||||
ret = "/";
|
||||
|
||||
for (int i = 0; i < data->path.size(); i++) {
|
||||
|
||||
if (i > 0)
|
||||
ret += "/";
|
||||
ret += data->path[i].operator String();
|
||||
}
|
||||
|
||||
for (int i = 0; i < data->subpath.size(); i++) {
|
||||
|
||||
ret += ":" + data->subpath[i].operator String();
|
||||
}
|
||||
|
||||
@ -188,24 +170,20 @@ NodePath::operator String() const {
|
||||
}
|
||||
|
||||
NodePath::NodePath(const NodePath &p_path) {
|
||||
|
||||
data = NULL;
|
||||
|
||||
if (p_path.data && p_path.data->refcount.ref()) {
|
||||
|
||||
data = p_path.data;
|
||||
}
|
||||
}
|
||||
|
||||
Vector<StringName> NodePath::get_names() const {
|
||||
|
||||
if (data)
|
||||
return data->path;
|
||||
return Vector<StringName>();
|
||||
}
|
||||
|
||||
Vector<StringName> NodePath::get_subnames() const {
|
||||
|
||||
if (data)
|
||||
return data->subpath;
|
||||
return Vector<StringName>();
|
||||
@ -227,7 +205,6 @@ StringName NodePath::get_concatenated_subnames() const {
|
||||
}
|
||||
|
||||
NodePath NodePath::rel_path_to(const NodePath &p_np) const {
|
||||
|
||||
ERR_FAIL_COND_V(!is_absolute(), NodePath());
|
||||
ERR_FAIL_COND_V(!p_np.is_absolute(), NodePath());
|
||||
|
||||
@ -252,12 +229,10 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
|
||||
Vector<StringName> relpath;
|
||||
|
||||
for (int i = src_dirs.size() - 1; i > common_parent; i--) {
|
||||
|
||||
relpath.push_back("..");
|
||||
}
|
||||
|
||||
for (int i = common_parent + 1; i < dst_dirs.size(); i++) {
|
||||
|
||||
relpath.push_back(dst_dirs[i]);
|
||||
}
|
||||
|
||||
@ -268,7 +243,6 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
|
||||
}
|
||||
|
||||
NodePath NodePath::get_as_property_path() const {
|
||||
|
||||
if (!data || !data->path.size()) {
|
||||
return *this;
|
||||
} else {
|
||||
@ -286,7 +260,6 @@ NodePath NodePath::get_as_property_path() const {
|
||||
}
|
||||
|
||||
NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
|
||||
|
||||
data = NULL;
|
||||
|
||||
if (p_path.size() == 0)
|
||||
@ -301,7 +274,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
|
||||
}
|
||||
|
||||
NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute) {
|
||||
|
||||
data = NULL;
|
||||
|
||||
if (p_path.size() == 0 && p_subpath.size() == 0)
|
||||
@ -317,7 +289,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p
|
||||
}
|
||||
|
||||
void NodePath::simplify() {
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
for (int i = 0; i < data->path.size(); i++) {
|
||||
@ -341,14 +312,12 @@ void NodePath::simplify() {
|
||||
}
|
||||
|
||||
NodePath NodePath::simplified() const {
|
||||
|
||||
NodePath np = *this;
|
||||
np.simplify();
|
||||
return np;
|
||||
}
|
||||
|
||||
NodePath::NodePath(const String &p_path) {
|
||||
|
||||
data = NULL;
|
||||
|
||||
if (p_path.length() == 0)
|
||||
@ -364,13 +333,10 @@ NodePath::NodePath(const String &p_path) {
|
||||
int subpath_pos = path.find(":");
|
||||
|
||||
if (subpath_pos != -1) {
|
||||
|
||||
int from = subpath_pos + 1;
|
||||
|
||||
for (int i = from; i <= path.length(); i++) {
|
||||
|
||||
if (path[i] == ':' || path[i] == 0) {
|
||||
|
||||
String str = path.substr(from, i - from);
|
||||
if (str == "") {
|
||||
if (path[i] == 0)
|
||||
@ -388,13 +354,10 @@ NodePath::NodePath(const String &p_path) {
|
||||
}
|
||||
|
||||
for (int i = (int)absolute; i < path.length(); i++) {
|
||||
|
||||
if (path[i] == '/') {
|
||||
|
||||
last_is_slash = true;
|
||||
has_slashes = true;
|
||||
} else {
|
||||
|
||||
if (last_is_slash)
|
||||
slices++;
|
||||
|
||||
@ -420,11 +383,8 @@ NodePath::NodePath(const String &p_path) {
|
||||
int slice = 0;
|
||||
|
||||
for (int i = (int)absolute; i < path.length() + 1; i++) {
|
||||
|
||||
if (path[i] == '/' || path[i] == 0) {
|
||||
|
||||
if (!last_is_slash) {
|
||||
|
||||
String name = path.substr(from, i - from);
|
||||
ERR_FAIL_INDEX(slice, data->path.size());
|
||||
data->path.write[slice++] = name;
|
||||
@ -438,15 +398,12 @@ NodePath::NodePath(const String &p_path) {
|
||||
}
|
||||
|
||||
bool NodePath::is_empty() const {
|
||||
|
||||
return !data;
|
||||
}
|
||||
NodePath::NodePath() {
|
||||
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
NodePath::~NodePath() {
|
||||
|
||||
unref();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user